An algebra teacher drove by a farmyard full of chickens and pigs. The teacher happened to notice that there were a total of 100 heads and 270 legs. How many chickens were there? How many pigs were there? (must show work)