The question shows that the farmer has 17 sheep and all but 8 of them died. This sentence implies that all the sheep the farmer has died due to some reasons unknown except 8. That is, 9 sheep out of 17 died.

The mathematical representation of this is:

17-8=9

That is, the total number of sheep minus the sheep that are alive will give the number of sheep that died.