A,B=list(map(int,input().split())) Aa=[int(x) for x in list(str(A))] Bb=[int(x) for x in list(str(B))] la=len(Aa) lb=len(Bb) if(la>lb): print(A) elif(lb>la): print(B) else: for i in range(la): if(Aa[i]==4 and Bb[i]==7): print(A) break elif(Aa[i]==7 and Bb[i]==4): print(B) break else: if(Aa[i]>Bb[i]): print(A) break elif(Aa[i]