Under construction

Still being built. Things may change

Complete Stars

Time limit2sMemory limit512 MB

Summary
For each N, count the values k with 1 <= k < N/2 whose step visits every marked point, i.e. gcd(k, N) = 1.
Level

Medium4 of 10

Topics
Number theory, Math
Solved
No attempts yet

Problem

Fernando got a compass for his birthday, and his favorite pastime now is drawing stars. He first marks NN points on a circle, splitting it into NN arcs of equal length. He then draws a segment from one point to the kk-th point clockwise from it, and keeps drawing segments the same way until he returns to the starting point.

Depending on kk, the drawing passes through every marked point or through only some of them. A star that passes through every point is called complete. For example, when N=8N = 8 the four stars below can be drawn. Stars (a) and (c) are complete, while stars (b) and (d) are not.

The four stars that can be drawn when N = 8

The step kk is chosen in the range 1≤k<N1 \le k < N, and kk and N−kN - k produce the same drawing, so they count as one star.

Given NN, write a program that determines how many complete stars Fernando can draw.

Input

The input consists of several test cases. Each line holds a single integer NN, the number of arcs the circle was split into. The input continues until end of file.

Constraints

  • 3≤N<2313 \le N < 2^{31}

Output

For each test case, print a single integer on its own line, the number of complete stars that can be drawn.

Examples3

  1. Example 1

    Input
    3
    4
    5
    18
    36
    360
    2147483647
    
    Expected output
    1
    1
    2
    3
    6
    48
    1073741823
    
  2. Example 2

    Input
    3
    
    Expected output
    1
    
  3. Example 3

    Input
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    
    Expected output
    1
    1
    2
    1
    3
    2
    3
    2
    5
    2
    6
    3
    4
    4
    8
    3
    9
    4