N = int(input()) ans = 0 for x in range(1,N+1): word = str(x) num = len(word) tmp = 0 for s in word: if s == "8": tmp = 1 break ans += tmp print(ans)