import java.util.*; import java.io.*; import java.math.*; public class No293 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String a = sc.next(); String b = sc.next(); String aa = a.replace('4', '8'); String bb = b.replace('4', '8'); if(Integer.parseInt(aa) > Integer.parseInt(bb)) System.out.println(a); else System.out.println(b); } }