To do this problem, you have to make what is called a “system of equations” (2 related equations). One will relate to the number of chickens and cows, the other will relate to the numbers of legs. But in both equations, the variables “x” and “y”  will be the number of cows (x) and number of chickens (y)

You know that the farmer has 18 total animals, so x + y = 18.
You know that cows have 4 legs and chickens have 2 legs, and the 18 cows and chickens have 60 legs total, so 4x + 2y = 60.

Now, to “solve” the system of equations, you can take the simpler equation x+y = 18, and simplify it, to stand in for variables.
Since we want to find y, the number of chickens, let’s make this equation = x.
So, it is now x = 18 – y.

Now you can take 18-x and put it into the OTHER equation to stand in for y, so that you can solve for y.

4(18-y) + 2y = 60

Distribute around the parentheses…

72 – 4y + 2y = 60

Combine the y’s.

72 – 2y = 60

-72 from both sides

-2y = -12

Divide by -2!

y = 6

So, there are 6 chickens.

And, if you wanted to find the number of cows, you can plug the value for y into the equation again… 6 + x = 18 and solve for x.