#!/usr/bin/python def bye(x): print x; exit(0) a, b = raw_input().split() ha = max(len(a), len(b)) za = a.zfill(ha) zb = b.zfill(ha) for x, y in zip(za, zb): if x == y: continue if x == '4' and y == '7': bye(a) elif x == '7' and y == '4': bye(b) else: bye(a if x > y else b)