import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); String A = scan.next(); String B = scan.next(); scan.close(); int l1 = A.length(); int l2 = B.length(); if(l1 > l2) { System.out.println(A); }else if(l1 < l2) { System.out.println(B); }else { for(int i = 0; i < l1; i++) { char c1 = A.charAt(i); char c2 = B.charAt(i); if(c1 == '4' && c2 == '7') { System.out.println(A); System.exit(0); }else if(c1 == '7' && c2 == '4') { System.out.println(B); System.exit(0); }else if(c1 > c2) { System.out.println(A); System.exit(0); }else if(c1 < c2) { System.out.println(B); System.exit(0); } } } } }