n = int(input()) ccount = 0 for i in range(1,n+1): if i % 7 == 0: ccount += 1 elif str(i).count('7') > 0: ccount += 1 print(ccount)