def judge753(n):
    a=list(str(n))
    if str(n).replace('3','').replace('5','').replace('7','')=='' and '3' in a and '5' in a and '7' in a:
        return 1
    else:
        return 0
n=int(input())
count=0
for i in range(357,n+1):
    count+=judge753(i)
print(count) 