Credit card
The winner of the individual Vekua Cup received a substantial cash prize from the sponsors. To receive this prize, the participant needs to provide their credit card number. Unfortunately, he has forgotten the number but recalls one of its properties: in the n-ary numeral system, this natural number is composed of k > 2 distinct digits. Additionally, when this number is multiplied by 2, it results in a cyclic permutation of the original number. This property holds true when the number is multiplied by 3, 4, and so on, up to k.
Your task is to determine how many such numbers exist for a given n.
Input
The input consists of a single integer 3 ≤ n ≤ 1000, which represents the base of the numeral system.
Output
Output a single integer representing the count of numbers in the n-ary numeral system that possess the specified property.