# ABC114 C - 755
N = int(input())
ans = 0
for i in range(1,N,2):
    c7,c5,c3,c753= 0,0,0,0
    i = str(i)
    for j in range(len(str(i))):
        if i[j] == "7":
            c7 += 1
            c753 += 1
        elif i[j] == "5":
            c5 += 1
            c753 += 1
        elif i[j] == "3":
            c3 += 1
            c753 += 1
        else:
            break
    if c753 == len(str(i)) and c7 >= 1 and c5 >= 1 and c3 >= 1:
        ans += 1
print(ans)