import sys A,B=input().split() if len(A)len(B): print(A) sys.exit() f=0 n=len(A) for i in range(n): if f!=0: continue T=(A[i],B[i]) if T==("4","7") or T==("7","4"): if A[i]=="4": f=1 else: f=-1 elif A[i]!=B[i]: if int(A[i])