n=int(input())
c=0
for i in range(min(n+1,10000)):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(33333,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(33335,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(33337,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(33353,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(33355,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(33357,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(33373,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(33375,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(33377,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(33533,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(33535,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(33537,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(33553,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(33555,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(33557,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(33573,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(33575,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(33577,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(33733,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(33735,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(33737,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(33753,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(33755,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(33757,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(33773,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(33775,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(33777,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(35333,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(35335,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(35337,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(35353,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(35355,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(35357,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(35373,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(35375,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(35377,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(35533,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(35535,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(35537,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(35553,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(35555,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(35557,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(35573,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(35575,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(35577,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(35733,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(35735,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(35737,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(35753,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(35755,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(35757,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(35773,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(35775,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(35777,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(37333,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(37335,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(37337,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(37353,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(37355,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(37357,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(37373,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(37375,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(37377,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(37533,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(37535,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(37537,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(37553,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(37555,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(37557,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(37573,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(37575,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(37577,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(37733,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(37735,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(37737,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(37753,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(37755,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(37757,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(37773,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(37775,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(37777,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(53333,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(53335,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(53337,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(53353,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(53355,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(53357,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(53373,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(53375,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(53377,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(53533,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(53535,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(53537,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(53553,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(53555,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(53557,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(53573,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(53575,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(53577,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(53733,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(53735,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(53737,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(53753,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(53755,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(53757,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(53773,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(53775,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(53777,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(55333,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(55335,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(55337,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(55353,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(55355,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(55357,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(55373,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(55375,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(55377,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(55533,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(55535,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(55537,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(55553,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(55555,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(55557,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(55573,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(55575,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(55577,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(55733,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(55735,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(55737,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(55753,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(55755,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(55757,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(55773,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(55775,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(55777,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(57333,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(57335,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(57337,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(57353,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(57355,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(57357,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(57373,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(57375,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(57377,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(57533,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(57535,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(57537,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(57553,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(57555,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(57557,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(57573,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(57575,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(57577,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(57733,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(57735,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(57737,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(57753,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(57755,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(57757,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(57773,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(57775,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(57777,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(73333,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(73335,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(73337,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(73353,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(73355,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(73357,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(73373,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(73375,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(73377,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(73533,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(73535,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(73537,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(73553,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(73555,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(73557,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(73573,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(73575,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(73577,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(73733,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(73735,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(73737,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(73753,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(73755,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(73757,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(73773,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(73775,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(73777,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(75333,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(75335,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(75337,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(75353,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(75355,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(75357,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(75373,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(75375,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(75377,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(75533,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(75535,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(75537,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(75553,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(75555,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(75557,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(75573,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(75575,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(75577,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(75733,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(75735,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(75737,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(75753,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(75755,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(75757,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(75773,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(75775,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(75777,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(77333,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(77335,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(77337,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(77353,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(77355,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(77357,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(77373,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(77375,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(77377,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(77533,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(77535,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(77537,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(77553,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(77555,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(77557,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(77573,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(77575,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(77577,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(77733,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(77735,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(77737,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(77753,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(77755,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(77757,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(77773,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(77775,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for i in range(77777,n+1,100000):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
print(c)

Measured memory_bytes: 8952