def f(n): # 判断n是不是与7有关的数 c = 0 for i in range(1,n+1): if (i%7 == 0) or ('7' in str(i)): c += 1 return c n = int(input()) print(f(n))