Let c=cows and d=ducks
Create the following equations:
Total Animals. c + d = 20
Total Legs. 4c + 2d = 64
Using the first equation solve for d and substitute into the second equation and solve for c
d=20-c
4c + 2(20 - c) = 64
4c + 40 - 2c = 64
2c = 24
c=12
There were 12 cows