Let the number of goats be 'x'.
Therefore, the number of chicken will be 50-x
Total number of legs the goats will have= 4x (goats have 4 legs)
Total number of legs chickens will have= 2(50-x) (chickens have two legs).
4x + 2(50-x)=140
4x+100-2x=140
2x+100=140
2x=40
x=20.
There are 20 goats and 30 chickens.