A,B=raw_input().split() if len(A) > len(B): print A elif len(B) > len(A): print B else: ans=A for i in range(len(A)): if A[i]=='4' and B[i]=='7': ans=A break elif B[i]=='4' and A[i]=='7': ans=B break elif int(A[i]) > int(B[i]): ans=A break elif int(A[i]) < int(B[i]): ans=B break print ans