n = int(input()) eight = [str(i) for i in range(1, n+1) if "8" in str(i)] print(len(eight))