num = input() count = 0 for n in range(1, int(num) + 1): if "7" in str(n): count += 1 elif n % 7 == 0: count += 1 print(count)