Problem

Source: 2017 China Northern MO, Grade 11, Problem 8

Tags: number theory, prime numbers



On Qingqing Grassland, there are 7 sheep numberd $1,2,3,4,5,6,7$ and 2017 wolves numberd $1,2,\cdots,2017$. We have such strange rules: (1) Define $P(n)$: the number of prime numbers that are smaller than $n$. Only when $P(i)\equiv j\pmod7$, wolf $i$ may eat sheep $j$ (he can also choose not to eat the sheep). (2) If wolf $i$ eat sheep $j$, he will immediately turn into sheep $j$. (3) If a wolf can make sure not to be eaten, he really wants to experience life as a sheep. Assume that all wolves are very smart, then how many wolves will remain in the end?