The cows have just learned what a primitive root is! Given a prime *p*, a primitive root <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/f203bd9f1553a2d666452cec7d6f1f4f02a817fb.png" style="max-width: 100.0%;max-height: 100.0%;"/> is an integer *x* (1 ≤ *x* &lt; *p*) such that none of integers *x* - 1, *x*<sup class="upper-index">2</sup> - 1, ..., *x*<sup class="upper-index">*p* - 2</sup> - 1 are divisible by *p*, but *x*<sup class="upper-index">*p* - 1</sup> - 1 is. 

Unfortunately, computing primitive roots can be time consuming, so the cows need your help. Given a prime *p*, help the cows find the number of primitive roots <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/f203bd9f1553a2d666452cec7d6f1f4f02a817fb.png" style="max-width: 100.0%;max-height: 100.0%;"/>.
The input contains a single line containing an integer *p* (2 ≤ *p* &lt; 2000). It is guaranteed that *p* is a prime.
# Your code here
from math import ceil,gcd,factorial,sqrt,floor
import queue
import re
from itertools import permutations as p
from collections import Counter,deque
from sys import stdin,stdout
from bisect import bisect,insort,bisect_left,insort_left
def simplesieve(n):
    prime=[2]
    mark=[False]*(n+1)
    for p in range(3,n+1,2):
        if(mark[p]==False):
            prime.append(p)
            if(p*p<=n):
                for i in range(p*p,n+1,2*p):
                    mark[i]=True
    return prime
def segementedsieve(low,high):
    limit=floor(sqrt(high))
    primes=simplesieve(limit)
    prime = [True] * (high-low + 1)
    for i in primes:
        lower = (low//i)
        if lower <= 1:
            lower = i+i
        elif (low % i) != 0:
            lower = (lower * i) + i
        else:
            lower = lower*i
        for j in range(lower, high+1, i):
            prime[j-low] = False
    a=[]
    c=0
    for k in range(low, high + 1):
        if prime[k-low]:
            a.append(k)
    return a
def isprime(n):
    if(n==2):
        return True
    if(n%2==0 or n==1):
        return False
    for i in range(3,int(n**0.5)+1,2):
        if(n%i==0):
            return False
    return True
def binpow(a,b,m):
    r=1
    while(b>0):
        if(b&1):
            r=(r*a)%m
        a=(a*a)%m
        b>>=1
    return r
def lcm(a,b):
    return (a//gcd(a,b))*b
#gcd(a,b)=ax+by and 
def gcdExtended(a, b): 
    if(a==0):  
        return b,0,1
    g,x1,y1=gcdExtended(b%a,a) 
    x = y1 - (b//a) * x1 
    y = x1 
    return g,x,y
def dfs(graph,n,v,val):
    v[n]=1
    a=[n] 
    #c=0
    g=val[n]
    while(a!=[]):
        k=a.pop()
        for i in graph[k]:
            if(v[i]==0):
                g=gcd(g,val[i])
                v[i]=1
                a.append(i)
    #print(g,"hi")
    return g
def bfs(graph,s,dest):
    #v=[0]*n
   # d=[0]*n
    d=[-1]*10001
    v=[0]*10001
    d[s]=0
    v[s]=1
    q=queue.Queue()
    q.put(s)
    p=[0]*n
    p[s]=-1
    while(not q.empty()):
        l=q.get()
        for j in graph[l]:
            if(v[j]==0):
                v[j]=1
                q.put(j)
                d[j]=d[l]+1
                p[j]=l
    path=[]
    x=dest#given
    while(x!=-1):
        path.append(x)
        x=p[x]
    path.reverse()
    #print(d)
    return d
def calc(a,b,x,y,cnt):
    x+=cnt*b
    y-=cnt*a
    return x,y
#a=normalsieve(86028121)
#a=simplesieve(8602812)
n=int(input())
a=simplesieve(n-1)
print(len(a))

"""
    a,b,c,x1,x2,y1,y2=map(int,input().split())
    c=-c
    #x1,x2=map(int,input().split())
    #a=list(map(int,input().split()))
    #y1,y2=map(int,input().split())
    g,x,y=gcdExtended(a,b)
    #print(x,y)
    if(c%g!=0):
        print(0)
    else:
        x=x*(c//g)
        y=y*(c//g)
        signa=1
        signb=1
        if(a<0):
            x-=x
            signa=-1
        if(b<0):
            y-=y
            signb=-1
        a=a//g
        b=b//g
        x,y=calc(a,b,x,y,(x1-x)//b)
        if (x<x1):
            x,y=calc(a,b,x,y,signb)
        if (x>x2):
            print(0)
        else:
            lx1=x
            x,y=calc(a,b,x,y,(x2-x)//b)
            if (x>x2):
                x,y=calc(a,b,x,y,-signb)
            rx1=x
            x,y=calc(a,b,x, y, -(y1-y)//a)
            if(y<y1):
                x,y=calc(a,b,x,y,-signa)
            if (y>y2):
                print(0)
            else:
                lx2=x
                x,y=calc(a,b,x,y,-(y2-y)//a)
                if (y>y2):
                    x,y=calc(a,b,x,y,signa)
                rx2=x
                if(lx2>rx2):
                    lx2,rx2=rx2,lx2
                lx=max(lx1,lx2)
                rx=min(rx1,rx2)
                #print(lx1,lx2,rx1,rx2)
                if(lx>rx):
                    print(0)
                else:
                    print((rx-lx)//abs(b)+1)
"""
