A,B=raw_input().split() Ac=list(A) Bc=list(B) for i in range(len(Ac)): if Ac[i]=='4': Ac[i]='7' elif Ac[i]=='7': Ac[i]='4' for i in range(len(Bc)): if Bc[i]=='4': Bc[i]='7' elif Bc[i]=='7': Bc[i]='4' if int(''.join(map(str,Ac))) > int(''.join(map(str,Bc))): print A else: print B