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