import java.util.*; public class Main { public static void main (String[] args) { Scanner sc = new Scanner(System.in); Num a = new Num(sc.next().toCharArray()); Num b = new Num(sc.next().toCharArray()); if (a.compareTo(b) > 0) { System.out.println(a); } else { System.out.println(b); } } static class Num implements Comparable { char[] arr; public Num(char[] arr) { this.arr = arr; } public int compareTo(Num another) { if (arr.length == another.arr.length) { for (int i = 0; i < arr.length; i++) { if (arr[i] == another.arr[i]) { continue; } if (arr[i] == '4' && another.arr[i] == '7') { return 1; } else if (arr[i] == '7' && another.arr[i] == '4') { return -1; } else { return arr[i] - another.arr[i]; } } return 0; } else { return arr.length - another.arr.length; } } public String toString() { return new String(arr); } } }