import java.util.Scanner; public class No293 { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); String[] numList = scanner.nextLine().split(" "); System.out.println(compare(numList[0], numList[1]) > 0 ? numList[0] : numList[1]); scanner.close(); } private static int compare(String str1, String str2) { if(str1.length() > str2.length()) { return 1; } else if(str1.length() < str2.length()) { return -1; } else { for(int index = 0; index < str1.length(); index++) { char str1Char = str1.charAt(index); char str2Char = str2.charAt(index); if(str1Char == '4' && str2Char == '7' ) { return 1; } else if(str1Char == '7' && str2Char == '4') { return -1; } else { if(str1Char != str2Char) { return str1Char - str2Char; } } } return 0; } } }