def f(s): a, b = s.split() la, lb = len(a), len(b) if la > lb: return a if la < lb: return b for i in range(la): if a[i] != b[i]: if a[i]=="4" and b[i]=="7": return a if a[i]=="7" and b[i]=="4": return b return a if a[i]>b[i] else b print(f(input()))