import java.util.Scanner; public class Main{ public static void main(String... args){ Scanner scan = new Scanner(System.in); int a = scan.nextInt(); int b = scan.nextInt(); if(a < b){ System.out.println(getResult(b,a)); }else if(b < a){ System.out.println(getResult(a,b)); }else{ System.out.println(a); } } public static int getResult(int l,int s){ String l_s = String.valueOf(l); String s_s = String.valueOf(s); if(l_s.length() != s_s.length())return l; if(l_s.indexOf("7") == -1 || s_s.indexOf("7") == -1)return l; int result = 0; for(int i = 0; i < l_s.length(); i++){ if(l_s.charAt(i) == '4'){ result = l; break; }else if(s_s.charAt(i) == '4'){ result = s; break; } } return result; } }