a, b = list(map(int, input().split(' '))) def compare(a, b): def _compare(al, bl): if len(al) < len(bl): return True elif len(al) > len(bl) or (len(al) == 0 and len(bl) == 0): return False else: if al[0] == 4 and bl[0] == 7: return False elif al[0] == 7 and bl[0] == 4: return True elif al[0] != bl[0]: return al[0] < bl[0] else: return _compare(al[1:], bl[1:]) al = list(map(int, list(str(a)))) bl = list(map(int, list(str(b)))) return _compare(al, bl) if compare(a, b): print(b) else: print(a)