N = int(input()) ans = 0 for n in range(1, N+1): if "8" in str(n): ans += 1 print(ans)