a,b = raw_input().split() if len(a) > len(b): print a elif len(a) < len(b): print b else: for c,d in zip(a,b): if c == d: continue elif c == '4' and d == '7': print a break elif c == '7' and d == '4': print b break else: print a if c > d else b break