import java.util.Scanner; class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String A = sc.next(), B = sc.next(); sc.close(); if (A.length() > B.length()) System.out.print(A); else if (A.length() < B.length()) System.out.print(B); else { for (int i = 0; i < A.length(); ++i) { if (A.charAt(i) == '4' && B.charAt(i) == '7') { System.out.print(A); break; } else if (A.charAt(i) == '7' && B.charAt(i) == '4') { System.out.print(B); break; } else if (A.charAt(i) > B.charAt(i)) { System.out.print(A); break; } else if (A.charAt(i) < B.charAt(i)) { System.out.print(B); break; } } } } }