import sys input = sys.stdin.readline N=int(input()) ANS=0 for i in range(N+1): if "8" in str(i): ANS+=1 print(ANS)