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{ System.out.println(getResult(a,b)); } } 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; 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; } }