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{ String longer = ""; String shorter = ""; if (one.length() > two.length()){ longer = one; shorter = two; }else{ shorter = one; longer = two; } String[] arrayOne = longer.split(""); String[] arrayTwo = new String[longer.length()]; String[] x = shorter.split(""); int y = arrayTwo.length - x.length; for(int i = 0; i < arrayTwo.length; i++){ if(i < y){ arrayTwo[i] = "0"; }else{ arrayTwo[i] = x[i - y]; } } compare(longer, arrayOne, shorter, arrayTwo); } } 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); } } }