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