from sys import stdin def main(): A, B = input().split() if len(A) == len(B): a, b = '', '' for s in zip(A, B): if '4' in s and '7' in s: s = [s[1], s[0]] a += s[0] b += s[1] a, b = int(a), int(b) else: a, b = int(A), int(B) print(max(a, b)) input = lambda: stdin.readline().rstrip() main()