while True:
    try:
        num = int(input())
        count = 0
        for x in range(num):
            if ('7' in str(x+1)) or ((x+1) %7==0):
                count += 1
        print(count)
    except:
        pass