Chicken and rabbit in the same cage problem: there are a group of chickens and rabbits, the total number of legs is 2 times more than the total number of heads, 18, to find the number of rabbits Just tell me the formula and the solution

Chicken and rabbit in the same cage problem: there are a group of chickens and rabbits, the total number of legs is 2 times more than the total number of heads, 18, to find the number of rabbits Just tell me the formula and the solution

This is my own solution, I don't know if it is right
Suppose there are x rabbits and Y chickens
According to the meaning of the question, the equation is: 4x + 2Y = 2 (x + y) + 18
4x+2y=2x+2y+18
4x-2x=18
x=9
So there are nine rabbits