There are 20 sheep and 30 chickens.
If you multiply 20 by 4 you will get 80 (number of feet for 20 sheep). Next, multiply 30 by 2 to get 60 (number of feet per 30 chickens). If you add 60 and 80, you will get 140 feet and by adding 20 and 30 you get 50 heads. Thus meaning there are 20 sheep and 30 chickens.
I hope this helps!