import java.util.Scanner; public class Main_yukicoder293 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); char[] a = sc.next().toCharArray(); char[] b = sc.next().toCharArray(); if (a.length > b.length) { System.out.println(a); } else if (a.length < b.length) { System.out.println(b); } else { for (int i = 0; i < a.length; i++) { if (a[i] != b[i]) { if (a[i] == '4' && b[i] == '7') { System.out.println(a); break; } else if (a[i] == '7' && b[i] == '4') { System.out.println(b); break; } else if (a[i] > b[i]) { System.out.println(a); break; } else { System.out.println(b); break; } } } } sc.close(); } }