while True:
    try:
        n = int(input())
        if n < 7:
            print(0)
            continue
        count = 0
        for i in range(7, n+1):
            if i % 7 == 0 or '7' in str(i):
                count += 1
        print(count)
    except:
        break