#万事稳为先写法
n = input()
str_list = [str(x) for x in range(int(n)+1)]
int_list = [int(x) for x in range(int(n)+1)]
record =[] 
# 注意到字符串会把只由7组成的数字本身又算一次,还得让字符串不能是已经数过的7的倍数
count = 0 
for i in int_list:
    if i > 0:
        if i % 7 == 0:
            count += 1
            record.append(str(i))
for j in str_list:
    if j not in record: 
        if '7' in j:
            count += 1
print(count)

# 稳中简化:
# n = int(input())
# count = 0
# for i in range(1, n+1):
#     if i % 7 == 0 or '7' in str(i):
#         count += 1
# print(count)

# 一行流
# print(len([i for i in range(1,int(input())+1) if i % 7 == 0 or '7' in str(i)]))