s = set(['4','7']) def less(x,y): if x == y: return False if x in s and y in s: return x == '7' else: return x < y A,B = raw_input().split() a = len(A) b = len(B) if a > b: print A elif a < b: print B else: s = set(['4','7']) for i in xrange(a): if less(A[i],B[i]): print B break elif less(B[i],A[i]): print A break else: print A