n = int(input()) cnt = 0 s = "" ei = "8" for i in range(1,n+1): s = "" s += str(i) for a in s: if a == ei: cnt += 1 break print(cnt)