import math
while True:
    try:
        N=int(input())
        num = 0
        for i in range(1,N+1):
            if i%7==0 or '7' in str(i): #
                num+=1
        print(num)
    except:
           break