Let L and S be the number of large and small dogs respectively.
L+S=8 so we can say L=8-S
5S+8L=55, using L found above in this equation yields:
5S+8(8-S)=55
5S+64-8S=55
-3S+64=55
-3S=-9
S=3, since L=8-S
L=5
So Ryan walked 3 small dogs and 5 large dogs.