import java.util.*; public class Exercise80{ public static void main (String[] args){ Scanner sc = new Scanner(System.in); String one = sc.next(); String two = sc.next(); if(one.length() == two.length()){ String[] arrayOne = one.split(""); String[] arrayTwo = two.split(""); compare(one, arrayOne, two, arrayTwo); }else{ if (one.length() > two.length()){ System.out.println(one); }else{ System.out.println(two); } } } private static void compare(String one, String[] arrayOne, String two, String[] arrayTwo){ for(int i = 0; i < arrayOne.length; i++){ if(arrayOne[i].equals("4") && arrayTwo[i].equals("7")){ arrayOne[i] = "7"; arrayTwo[i] = "4"; }else if(arrayOne[i].equals("7") && arrayTwo[i].equals("4")){ arrayOne[i] = "4"; arrayTwo[i] = "7"; } } String newOne = String.join("", arrayOne); String newTwo = String.join("", arrayTwo); if(Integer.parseInt(newOne) > Integer.parseInt(newTwo)){ System.out.println(one); }else{ System.out.println(two); } } }