import java.util.Scanner; public class Test { public static Scanner sc = new Scanner(System.in); public static void main(String[] args) { String s1 = sc.next(), s2 = sc.next(); char c1, c2; if (s1.length() < s2.length()) { System.out.println(s2); return; } else if (s1.length() > s2.length()) { System.out.println(s1); return; } else { for (int i = 0; i < s1.length(); i++) { c1 = s1.charAt(i); c2 = s2.charAt(i); if (c1 == '4' && c2 == '7') { System.out.println(s1); return; } else if (c1 == '7' && c2 == '4') { System.out.println(s2); return; } else if (c1 > c2) { System.out.println(s1); return; } else if (c1 < c2) { System.out.println(s2); return; } } } } }