import java.util.*; public class Main { private static Scanner sc = new Scanner(System.in); public static void main(String[] args) throws Exception { String a = sc.next(); String b = sc.next(); int la = a.length(); int lb = b.length(); if (la > lb) { System.out.println(a); return; } else if (lb > la) { System.out.println(b); return; } for (int i = 0;i < la;i++) { int ai = Integer.parseInt(a.substring(i,i+1)); int bi = Integer.parseInt(b.substring(i,i+1)); if (ai == bi) continue; if (ai == 4 && bi == 7) { System.out.println(a); } else if (ai == 7 && bi == 4) { System.out.println(b); } else { if (ai > bi) { System.out.println(a); } else if (bi > ai) { System.out.println(b); } } return; } } }