The Josephs problem is notoriously known. For those who are not familiar with the problem, among n people numbered 1, 2, . . . , n, standing in circle every mth is going to be executed and only the life of the last remaining person will be saved. Joseph was smart enough to choose the position of the last remaining person, thus saving his life to give the message about the incident.
The persons are eliminated in a very peculiar order; m is a dynamical variable, which each time takes a different value corresponding to the prime numbers succession (2,3,5,7,...). So in order to kill the i-th person, Josephs cousin counts up to the i-th prime.
Each line with 1 integers, n. n is the number of people.Input terminated by EOF.
Testcase 1 : 1<=n<100
Testcase 2 : 100<=n<500
Testcase 3 : 500<=n<1000
Testcase 4 : 1000<=n<3000
The output will consist in separate lines containing the position of the person which life will be saved.