import java.util.*; import java.io.*; public class Main { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] first = br.readLine().split(" ", 2); char[] aArr = first[0].toCharArray(); char[] bArr = first[1].toCharArray(); if (aArr.length != bArr.length) { if (aArr.length > bArr.length) { System.out.println(aArr); } else { System.out.println(bArr); } return; } for (int i = 0; i < aArr.length; i++) { if (aArr[i] == bArr[i]) { continue; } if (aArr[i] == '4' && bArr[i] == '7') { System.out.println(aArr); } else if (aArr[i] == '7' && bArr[i] == '4') { System.out.println(bArr); } else if (aArr[i] > bArr[i]) { System.out.println(aArr); } else { System.out.println(bArr); } return; } } }