while True:
    try:
        n = int(input())
        num=0
        for i in range(1,n+1):
            str_i = str(i)
            if i%7==0:
                num+=1
            elif '7' in str_i:
                num+=1
        print(num) 
    except:
        break