A farmer has 10 animals, all chickens and horses. There are a total of 22 legs. How many of each animal does the farmer have?