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