nums = 0
for i in range(12345678, 98765433):
sent = str(i)
words =list(c for c in sent)
ban = ['4', '3', '9', '6']
ord = 0
for j in words:
if ord == 4:
break
if j != ban[ord]:
continue
elif j == ban[ord]:
ord += 1
if ord < 4:
nums += 1
print(nums)