Chris P. Bacon owns 13 animals. Some are chickens and some are pigs. There are 40 legs in all. How many of each animal does Chris own?

it would be helpful to get the system for the equation as well.