N = int(input()) count = 0 for x in range(N+1): buf = str(x) count += 1 if buf.count('8') > 0 else 0 print(count)