Credit card#4308

Credit card

2 secondi
64 megabyte
Facile

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 -ary numeral system, this natural number is composed of k > 2 distinct digits. Additionally, when this number is multiplied by , it results in a cyclic permutation of the original number. This property holds true when the number is multiplied by , , and so on, up to .

Your task is to determine how many such numbers exist for a given .

Input

The input consists of a single integer 3 \leq n \leq 1000, which represents the base of the numeral system.

Output

Output a single integer representing the count of numbers in the -ary numeral system that possess the specified property.

Esempi

Esempio 1

Loading
Loading