a, b = map(str,input().split()) if len(a)>len(b): print(a) exit() if len(b)>len(a): print(b) exit() l = len(a) for i in range(l): if a[i] == b[i]: continue if a[i] == '4' and b[i] == '7': print(a) exit() if a[i] == '7' and b[i] == '4': print(b) exit() if int(a[i]) > int(b[i]): print(a) exit() if int(b[i]) > int(a[i]): print(b) exit()