两种情况,一个是7的倍数,一个是含7,后者只需要按位判断即可

while True:
    try:
        num1 = int(input())

        ans = 0

        for i in range(1,num1+1):
            if(i%7 == 0):
                ans += 1
                continue
            k = i
            while(k//10 != 0):
                if(k%10 == 7):
                    ans += 1
                    break
                else:
                    k = k // 10
                if(k == 7):
                    ans += 1

        print(ans)
    except:
        break