import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String a = sc.next(); String b = sc.next(); String A = ""; String B = ""; for(int i = 0; i < a.length(); i++) { char c = a.charAt(i); if(c == '4') A += "7"; if(c == '7') A += "4"; if(c != '4' && c != '7') A += String.valueOf(c); } for(int i = 0; i < b.length(); i++) { char c = b.charAt(i); if(c == '4') B += "7"; if(c == '7') B += "4"; if(c != '4' && c != '7') B += String.valueOf(c); } String ans = a; if(Long.parseLong(A) < Long.parseLong(B)) ans = b; System.out.println(ans); } }