This is obviously a problem for system of two equations. Let Z=number of zebras (4 legged) P=number peacocks (2 legged).
We know that P=8-Z (total of 8 animals) and 4Z+2P=4Z+2(8-Z)=28 expand and solve for Z 4Z+16-2Z=28 2Z=12 Z=6 There are 6 zebras.
Another way to solve, without pen and paper: if all are zebras, there are 4*8=32 legs, or 4 legs too many. Each exchange with a peacock reduces 2 legs, so we exchange 2 zebras with 2 peacocks to get 6 zebras.