import java.util.Arrays; import java.util.HashSet; import java.util.LinkedList; import java.util.Scanner; import java.util.Set; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); final long A = sc.nextLong(); final long B = sc.nextLong(); final char[] A_ch = Long.toString(A).toCharArray(); final char[] B_ch = Long.toString(B).toCharArray(); if(A_ch.length < B_ch.length){ System.out.println(B); }else if(A_ch.length > B_ch.length){ System.out.println(A); }else{ for(int i = 0; i < A_ch.length; i++){ if(A_ch[i] == '4' && B_ch[i] == '7'){ System.out.println(A); break; }else if(A_ch[i] == '7' && B_ch[i] == '4'){ System.out.println(B); break; }else if(A_ch[i] > B_ch[i]){ System.out.println(A); break; }else if(A_ch[i] < B_ch[i]){ System.out.println(B); break; } } } } }