There are both chickens and rabbits in the chicken cage. There are 12 counting legs, 4 heads, how many chickens? How many rabbits?

There are both chickens and rabbits in the chicken cage. There are 12 counting legs, 4 heads, how many chickens? How many rabbits?

Suppose there are x chickens, then there are 4-x rabbits, two chickens and four rabbits
2X+4*(4-X)=12
X=2
A: there are two chickens and two rabbits