# -*- coding: utf-8 -*- """ No.293 4>7の世界 https://yukicoder.me/problems/no/293 """ import sys from sys import stdin input = stdin.readline class Number: def __init__(self, s): self.s = s def __lt__(self, other): if len(self.s) < len(other.s): return True elif len(self.s) == len(other.s): for a, b in zip(self.s, other.s): if a != b: if (a == '4' and b == '7') or (a == '7' and b == '4'): return not a < b else: return a < b return False else: return False def __str__(self): return self.s def main(args): A, B = map(Number, input().split()) if A < B: print(B) else: print(A) if __name__ == '__main__': main(sys.argv[1:])