import java.io.*; import java.util.*; class Main { public static void out (Object o) { System.out.println(o); } public static String max (String a , String b) { if (a.length() != b.length()) return a.length() > b.length() ? a : b; for (int i = 0; i < a.length(); i++) { int n = a.charAt(i) - '0'; int m = b.charAt(i) - '0'; if (n == 4 && m == 7) { return a; } else if (n == 7 && m == 4) { return b; } else if (n != m) { return n > m ? a : b; } } return a; } public static void main (String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] line = br.readLine().split(" "); out(max(line[0] , line[1])); } }