import java.util.*; import java.math.*; import java.awt.geom.*; import java.io.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String a = sc.next(); String b = sc.next(); int ans = compare(a,b); if(ans > 0) { System.out.println(a); } else if (ans < 0){ System.out.println(b); } } static int compare(String a, String b) { if(a.equals(b)) return 0; if(a.length() > b.length()) return 1; else if(a.length() < b.length()) return -1; else { for(int i = 0; i < a.length(); i++) { if(a.charAt(i) == b.charAt(i)) continue; if(a.charAt(i) == '4' && b.charAt(i) == '7') { return 1; } if(a.charAt(i) == '7' && b.charAt(i) == '4') { return -1; } return Integer.parseInt(String.valueOf(String.valueOf(a.charAt(i)))) - Integer.parseInt(String.valueOf(String.valueOf(b.charAt(i)))); } } return 0; } }