i=1
s=0
n=int(input())
while i<=n:
a=i//1000
b=i//100%10
c=i//10%10
d=i%10
if i%3==2 and i%5==3 and i%7==2:
s+=1
i+=1
print(s)
/**************************************************************
Problem: 1055
User: admin
Language: Python
Result: Accepted
Time:88 ms
Memory:34480 kb
****************************************************************/