最简单的一题了吧

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