import java.util.*; public class Main { public static void main (String[] args) { Scanner sc = new Scanner(System.in); String a = sc.next(); String b = sc.next(); 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++) { char ca = a.charAt(i); char cb = b.charAt(i); if ((ca == '4' && cb == '7') || ca > cb) { System.out.println(a); return; } else if ((ca == '7' && cb == '4') || ca < cb) { System.out.println(b); return; } } } } }