import java.util.*;
import java.io.*;

public class Main {
	private static void solve(){
		//Implement solution here.
		int n = ni();
		int tlim = ni();
		int minc = Integer.MAX_VALUE;
		for(int i = 0; i < n ; i++) {
			int c = ni();
			int t = ni();
			if(t > tlim) {
				continue;
			}else {
				minc = Math.min(minc, c);
			}
		}
		if(minc == Integer.MAX_VALUE) {
			System.out.println("TLE");
		}else {
			System.out.println(minc);
		}
	}
	
	private static int dfs(int dig, int cur, int max) {
		int result = 0;	
		if(dig >= 3) {
			if(dig <= Integer.toString(max).length()) {
				if(cur <= max) {
					if(is753(cur))result++;
				} else {
					return 0;
				}
			} else {
				return 0;
			}
		}	
		dig++;
		result += dfs(dig, cur * 10 + 3, max) + dfs(dig, cur * 10 + 5, max) + dfs(dig, cur * 10 + 7, max);
		return result;
	}

	private static boolean is753(int in) {
		boolean[] flags = new boolean[3];
		char[] inca = Integer.toString(in).toCharArray();
		for(char c:inca) {
			if(c == '3')flags[0] = true;
			if(c == '5')flags[1] = true;
			if(c == '7')flags[2] = true;
		}
		
		return flags[0] && flags[1] && flags[2];
	}
	//Switch input source (stdin/file)
	private static Scanner scanner = new Scanner(System.in);
	public static void main(String[] args){
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				scanner = new Scanner(new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath)))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		solve();
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(scanner.nextLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
} import java.util.*; util.* java import java.io.*; io.* java public class Main {
	private static void solve(){
		//Implement solution here.
		int n = ni();
		int tlim = ni();
		int minc = Integer.MAX_VALUE;
		for(int i = 0; i < n ; i++) {
			int c = ni();
			int t = ni();
			if(t > tlim) {
				continue;
			}else {
				minc = Math.min(minc, c);
			}
		}
		if(minc == Integer.MAX_VALUE) {
			System.out.println("TLE");
		}else {
			System.out.println(minc);
		}
	}
	
	private static int dfs(int dig, int cur, int max) {
		int result = 0;	
		if(dig >= 3) {
			if(dig <= Integer.toString(max).length()) {
				if(cur <= max) {
					if(is753(cur))result++;
				} else {
					return 0;
				}
			} else {
				return 0;
			}
		}	
		dig++;
		result += dfs(dig, cur * 10 + 3, max) + dfs(dig, cur * 10 + 5, max) + dfs(dig, cur * 10 + 7, max);
		return result;
	}

	private static boolean is753(int in) {
		boolean[] flags = new boolean[3];
		char[] inca = Integer.toString(in).toCharArray();
		for(char c:inca) {
			if(c == '3')flags[0] = true;
			if(c == '5')flags[1] = true;
			if(c == '7')flags[2] = true;
		}
		
		return flags[0] && flags[1] && flags[2];
	}
	//Switch input source (stdin/file)
	private static Scanner scanner = new Scanner(System.in);
	public static void main(String[] args){
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				scanner = new Scanner(new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath)))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		solve();
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(scanner.nextLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
} Main //Switch input source (stdin/file)
	private static Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) //Input read utility
	private static StringTokenizer tokenizer = null; tokenizer null private static void solve(){
		//Implement solution here.
		int n = ni();
		int tlim = ni();
		int minc = Integer.MAX_VALUE;
		for(int i = 0; i < n ; i++) {
			int c = ni();
			int t = ni();
			if(t > tlim) {
				continue;
			}else {
				minc = Math.min(minc, c);
			}
		}
		if(minc == Integer.MAX_VALUE) {
			System.out.println("TLE");
		}else {
			System.out.println(minc);
		}
	} solve {
		//Implement solution here.
		int n = ni();
		int tlim = ni();
		int minc = Integer.MAX_VALUE;
		for(int i = 0; i < n ; i++) {
			int c = ni();
			int t = ni();
			if(t > tlim) {
				continue;
			}else {
				minc = Math.min(minc, c);
			}
		}
		if(minc == Integer.MAX_VALUE) {
			System.out.println("TLE");
		}else {
			System.out.println(minc);
		}
	} int n = ni(); n ni() ni int tlim = ni(); tlim ni() ni int minc = Integer.MAX_VALUE; minc Integer.MAX_VALUE Integer Integer.MAX_VALUE for(int i = 0; i < n ; i++) {
			int c = ni();
			int t = ni();
			if(t > tlim) {
				continue;
			}else {
				minc = Math.min(minc, c);
			}
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			int c = ni();
			int t = ni();
			if(t > tlim) {
				continue;
			}else {
				minc = Math.min(minc, c);
			}
		} {
			int c = ni();
			int t = ni();
			if(t > tlim) {
				continue;
			}else {
				minc = Math.min(minc, c);
			}
		} int c = ni(); c ni() ni int t = ni(); t ni() ni if(t > tlim) {
				continue;
			}else {
				minc = Math.min(minc, c);
			} t > tlim t tlim {
				continue;
			} continue; {
				minc = Math.min(minc, c);
			} minc = Math.min(minc, c) minc Math.min(minc, c) Math.min Math minc c if(minc == Integer.MAX_VALUE) {
			System.out.println("TLE");
		}else {
			System.out.println(minc);
		} minc == Integer.MAX_VALUE minc Integer.MAX_VALUE Integer Integer.MAX_VALUE {
			System.out.println("TLE");
		} System.out.println("TLE") System.out.println System.out System System.out "TLE" {
			System.out.println(minc);
		} System.out.println(minc) System.out.println System.out System System.out minc private static int dfs(int dig, int cur, int max) {
		int result = 0;	
		if(dig >= 3) {
			if(dig <= Integer.toString(max).length()) {
				if(cur <= max) {
					if(is753(cur))result++;
				} else {
					return 0;
				}
			} else {
				return 0;
			}
		}	
		dig++;
		result += dfs(dig, cur * 10 + 3, max) + dfs(dig, cur * 10 + 5, max) + dfs(dig, cur * 10 + 7, max);
		return result;
	} dfs {
		int result = 0;	
		if(dig >= 3) {
			if(dig <= Integer.toString(max).length()) {
				if(cur <= max) {
					if(is753(cur))result++;
				} else {
					return 0;
				}
			} else {
				return 0;
			}
		}	
		dig++;
		result += dfs(dig, cur * 10 + 3, max) + dfs(dig, cur * 10 + 5, max) + dfs(dig, cur * 10 + 7, max);
		return result;
	} int result = 0; result 0 if(dig >= 3) {
			if(dig <= Integer.toString(max).length()) {
				if(cur <= max) {
					if(is753(cur))result++;
				} else {
					return 0;
				}
			} else {
				return 0;
			}
		} dig >= 3 dig 3 {
			if(dig <= Integer.toString(max).length()) {
				if(cur <= max) {
					if(is753(cur))result++;
				} else {
					return 0;
				}
			} else {
				return 0;
			}
		} if(dig <= Integer.toString(max).length()) {
				if(cur <= max) {
					if(is753(cur))result++;
				} else {
					return 0;
				}
			} else {
				return 0;
			} dig <= Integer.toString(max).length() dig Integer.toString(max).length() Integer.toString(max).length Integer.toString(max) Integer.toString Integer max {
				if(cur <= max) {
					if(is753(cur))result++;
				} else {
					return 0;
				}
			} if(cur <= max) {
					if(is753(cur))result++;
				} else {
					return 0;
				} cur <= max cur max {
					if(is753(cur))result++;
				} if(is753(cur))result++; is753(cur) is753 cur result++ result {
					return 0;
				} return 0; 0 {
				return 0;
			} return 0; 0 dig++ dig result += dfs(dig, cur * 10 + 3, max) + dfs(dig, cur * 10 + 5, max) + dfs(dig, cur * 10 + 7, max) result dfs(dig, cur * 10 + 3, max) + dfs(dig, cur * 10 + 5, max) + dfs(dig, cur * 10 + 7, max) dfs(dig, cur * 10 + 3, max) + dfs(dig, cur * 10 + 5, max) + dfs(dig, cur * 10 + 7, max) dfs(dig, cur * 10 + 3, max) dfs dig cur * 10 + 3 cur * 10 cur 10 3 max dfs(dig, cur * 10 + 5, max) dfs dig cur * 10 + 5 cur * 10 cur 10 5 max dfs(dig, cur * 10 + 7, max) dfs dig cur * 10 + 7 cur * 10 cur 10 7 max return result; result int dig dig int cur cur int max max private static boolean is753(int in) {
		boolean[] flags = new boolean[3];
		char[] inca = Integer.toString(in).toCharArray();
		for(char c:inca) {
			if(c == '3')flags[0] = true;
			if(c == '5')flags[1] = true;
			if(c == '7')flags[2] = true;
		}
		
		return flags[0] && flags[1] && flags[2];
	} is753 {
		boolean[] flags = new boolean[3];
		char[] inca = Integer.toString(in).toCharArray();
		for(char c:inca) {
			if(c == '3')flags[0] = true;
			if(c == '5')flags[1] = true;
			if(c == '7')flags[2] = true;
		}
		
		return flags[0] && flags[1] && flags[2];
	} boolean[] flags = new boolean[3]; flags new boolean[3] 3 char[] inca = Integer.toString(in).toCharArray(); inca Integer.toString(in).toCharArray() Integer.toString(in).toCharArray Integer.toString(in) Integer.toString Integer in for(char c:inca) {
			if(c == '3')flags[0] = true;
			if(c == '5')flags[1] = true;
			if(c == '7')flags[2] = true;
		} char c inca {
			if(c == '3')flags[0] = true;
			if(c == '5')flags[1] = true;
			if(c == '7')flags[2] = true;
		} {
			if(c == '3')flags[0] = true;
			if(c == '5')flags[1] = true;
			if(c == '7')flags[2] = true;
		} if(c == '3')flags[0] = true; c == '3' c '3' flags[0] = true flags[0] flags 0 true if(c == '5')flags[1] = true; c == '5' c '5' flags[1] = true flags[1] flags 1 true if(c == '7')flags[2] = true; c == '7' c '7' flags[2] = true flags[2] flags 2 true return flags[0] && flags[1] && flags[2]; flags[0] && flags[1] && flags[2] flags[0] && flags[1] && flags[2] flags[0] flags 0 flags[1] flags 1 flags[2] flags 2 int in in public static void main(String[] args){
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				scanner = new Scanner(new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath)))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		solve();
	} main {
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				scanner = new Scanner(new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath)))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		solve();
	} String debugDataPath = System.getenv("DD_PATH"); debugDataPath System.getenv("DD_PATH") System.getenv System "DD_PATH" if(debugDataPath != null){
			try{
				scanner = new Scanner(new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath)))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		} debugDataPath != null debugDataPath null {
			try{
				scanner = new Scanner(new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath)))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		} try{
				scanner = new Scanner(new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath)))));
			}catch(Exception e){
				throw new RuntimeException(e);
			} catch(Exception e){
				throw new RuntimeException(e);
			} Exception e {
				throw new RuntimeException(e);
			} throw new RuntimeException(e); new RuntimeException(e) {
				scanner = new Scanner(new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath)))));
			} scanner = new Scanner(new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))))) scanner new Scanner(new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))))) solve() solve String[] args args public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(scanner.nextLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	} next {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(scanner.nextLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	} while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(scanner.nextLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		} tokenizer == null || !tokenizer.hasMoreTokens() tokenizer == null tokenizer null !tokenizer.hasMoreTokens() tokenizer.hasMoreTokens() tokenizer.hasMoreTokens tokenizer {
			try {
				tokenizer = new StringTokenizer(scanner.nextLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		} try {
				tokenizer = new StringTokenizer(scanner.nextLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			} catch (Exception e) {
				throw new RuntimeException(e);
			} Exception e {
				throw new RuntimeException(e);
			} throw new RuntimeException(e); new RuntimeException(e) {
				tokenizer = new StringTokenizer(scanner.nextLine());
			} tokenizer = new StringTokenizer(scanner.nextLine()) tokenizer new StringTokenizer(scanner.nextLine()) return tokenizer.nextToken(); tokenizer.nextToken() tokenizer.nextToken tokenizer //Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	} ni {
		return Integer.parseInt(next());
	} return Integer.parseInt(next()); Integer.parseInt(next()) Integer.parseInt Integer next() next //Get next single long
	private static long nl() {
		return Long.parseLong(next());
	} nl {
		return Long.parseLong(next());
	} return Long.parseLong(next()); Long.parseLong(next()) Long.parseLong Long next() next //Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	} nd {
		return Double.parseDouble(next());
	} return Double.parseDouble(next()); Double.parseDouble(next()) Double.parseDouble Double next() next //Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	} na {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	} int[] a = new int[n]; a new int[n] n for (int i = 0; i < n; i++)
			a[i] = ni(); int i = 0; int i = 0; i 0 i < n i n i++ i++ i a[i] = ni(); a[i] = ni() a[i] a i ni() ni return a; a int n n //Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	} ns {
		return next().toCharArray();
	} return next().toCharArray(); next().toCharArray() next().toCharArray next() next //Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	} nal {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	} long[] a = new long[n]; a new long[n] n for (int i = 0; i < n; i++)
			a[i] = nl(); int i = 0; int i = 0; i 0 i < n i n i++ i++ i a[i] = nl(); a[i] = nl() a[i] a i nl() nl return a; a int n n public class Main {
	private static void solve(){
		//Implement solution here.
		int n = ni();
		int tlim = ni();
		int minc = Integer.MAX_VALUE;
		for(int i = 0; i < n ; i++) {
			int c = ni();
			int t = ni();
			if(t > tlim) {
				continue;
			}else {
				minc = Math.min(minc, c);
			}
		}
		if(minc == Integer.MAX_VALUE) {
			System.out.println("TLE");
		}else {
			System.out.println(minc);
		}
	}
	
	private static int dfs(int dig, int cur, int max) {
		int result = 0;	
		if(dig >= 3) {
			if(dig <= Integer.toString(max).length()) {
				if(cur <= max) {
					if(is753(cur))result++;
				} else {
					return 0;
				}
			} else {
				return 0;
			}
		}	
		dig++;
		result += dfs(dig, cur * 10 + 3, max) + dfs(dig, cur * 10 + 5, max) + dfs(dig, cur * 10 + 7, max);
		return result;
	}

	private static boolean is753(int in) {
		boolean[] flags = new boolean[3];
		char[] inca = Integer.toString(in).toCharArray();
		for(char c:inca) {
			if(c == '3')flags[0] = true;
			if(c == '5')flags[1] = true;
			if(c == '7')flags[2] = true;
		}
		
		return flags[0] && flags[1] && flags[2];
	}
	//Switch input source (stdin/file)
	private static Scanner scanner = new Scanner(System.in);
	public static void main(String[] args){
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				scanner = new Scanner(new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath)))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		solve();
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(scanner.nextLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
} public class Main {
	private static void solve(){
		//Implement solution here.
		int n = ni();
		int tlim = ni();
		int minc = Integer.MAX_VALUE;
		for(int i = 0; i < n ; i++) {
			int c = ni();
			int t = ni();
			if(t > tlim) {
				continue;
			}else {
				minc = Math.min(minc, c);
			}
		}
		if(minc == Integer.MAX_VALUE) {
			System.out.println("TLE");
		}else {
			System.out.println(minc);
		}
	}
	
	private static int dfs(int dig, int cur, int max) {
		int result = 0;	
		if(dig >= 3) {
			if(dig <= Integer.toString(max).length()) {
				if(cur <= max) {
					if(is753(cur))result++;
				} else {
					return 0;
				}
			} else {
				return 0;
			}
		}	
		dig++;
		result += dfs(dig, cur * 10 + 3, max) + dfs(dig, cur * 10 + 5, max) + dfs(dig, cur * 10 + 7, max);
		return result;
	}

	private static boolean is753(int in) {
		boolean[] flags = new boolean[3];
		char[] inca = Integer.toString(in).toCharArray();
		for(char c:inca) {
			if(c == '3')flags[0] = true;
			if(c == '5')flags[1] = true;
			if(c == '7')flags[2] = true;
		}
		
		return flags[0] && flags[1] && flags[2];
	}
	//Switch input source (stdin/file)
	private static Scanner scanner = new Scanner(System.in);
	public static void main(String[] args){
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				scanner = new Scanner(new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath)))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		solve();
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(scanner.nextLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
} Main
import java.util.*;
import java.io.*;

public class Main {
	private static void solve(){
		//Implement solution here.
		int n = ni();
		int tlim = ni();
		int minc = Integer.MAX_VALUE;
		for(int i = 0; i < n ; i++) {
			int c = ni();
			int t = ni();
			if(t > tlim) {
				continue;
			}else {
				minc = Math.min(minc, c);
			}
		}
		if(minc == Integer.MAX_VALUE) {
			System.out.println("TLE");
		}else {
			System.out.println(minc);
		}
	}
	
	private static int dfs(int dig, int cur, int max) {
		int result = 0;	
		if(dig >= 3) {
			if(dig <= Integer.toString(max).length()) {
				if(cur <= max) {
					if(is753(cur))result++;
				} else {
					return 0;
				}
			} else {
				return 0;
			}
		}	
		dig++;
		result += dfs(dig, cur * 10 + 3, max) + dfs(dig, cur * 10 + 5, max) + dfs(dig, cur * 10 + 7, max);
		return result;
	}

	private static boolean is753(int in) {
		boolean[] flags = new boolean[3];
		char[] inca = Integer.toString(in).toCharArray();
		for(char c:inca) {
			if(c == '3')flags[0] = true;
			if(c == '5')flags[1] = true;
			if(c == '7')flags[2] = true;
		}
		
		return flags[0] && flags[1] && flags[2];
	}
	//Switch input source (stdin/file)
	private static Scanner scanner = new Scanner(System.in);
	public static void main(String[] args){
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				scanner = new Scanner(new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath)))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		solve();
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(scanner.nextLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}