from fractions import gcd from heapq import* import math from collections import defaultdict, Counter import sys sys.setrecursionlimit(10 ** 7) MOD = 10 ** 9 + 7 def main(): a, b = map(int, input().split()) sa,sb = str(a),str(b) if len(sa) > len(sb): print(a) elif len(sa) < len(sb): print(b) else: for i in range(len(sa)): if (sa[i] == "4" and sb[i] == "7"): print(a) exit() elif (sa[i] == "7" and sb[i] == "4"): print(b) exit() elif int(sa[i]) > int(sb[i]): print(a) exit() elif int(sa[i]) < int(sb[i]): print(b) exit() if __name__ == '__main__': main()