Problem:
 Score : 300 points    Problem Statement You are given an integer N . Among the integers between 1 and N (inclusive), how many Shichi-Go-San numbers (literally "Seven-Five-Three numbers") are there?  Here, a Shichi-Go-San number is a positive integer that satisfies the following condition:   When the number is written in base ten, each of the digits 7 , 5 and 3 appears at least once, and the other digits never appear.       Constraints  1 \leq N < 10^9  N is an integer.         Input Input is given from Standard Input in the following format:  N       Output Print the number of the Shichi-Go-San numbers between 1 and N (inclusive).        Sample Input 1 575      Sample Output 1 4  There are four Shichi-Go-San numbers not greater than 575 : 357, 375, 537 and 573 .       Sample Input 2 3600      Sample Output 2 13  There are 13 Shichi-Go-San numbers not greater than 3600 : the above four numbers, 735, 753, 3357, 3375, 3537, 3557, 3573, 3575 and 3577 .       Sample Input 3 999999999      Sample Output 3 26484

Solution (Python):
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)