import java.util.*; public class Yuki293 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String a = sc.next(); String b = sc.next(); System.out.println(less(a, b) ? a : b); } public static boolean less(String a, String b) { char[] l_a = a.toCharArray(); char[] l_b = b.toCharArray(); if (l_a.length != l_b.length) { return l_a.length > l_b.length; } int n = l_a.length; for (int i = 0; i < n; i++) { if (l_a[i] != l_b[i]) { if (l_a[i] == '4' && l_b[i] == '7' || l_a[i] == '7' && l_b[i] == '4') { return l_a[i] < l_b[i]; } else { return l_a[i] > l_b[i]; } } } return true; } }