n = int(input())
cnt = 0
for i in range(1,n+1):
    if "7" in str(i) or i%7  == 0:
        cnt += 1
print(cnt)