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))] d={} for i in range(0,10): d[i]=i d[4]=7 d[7]=4 la=len(Aa) lb=len(Bb) if(la>lb): print(A) if(lb>la): print(B) else: for i in range(la): if(d[Aa[i]>d[Bb[i]]]): print(A) break elif(d[Aa[i]]