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