n = str(input())
a = str(input())
b = str(input())
a = set(a)
b = set(b)
c = set(' ')
a = a - c
b = b - c
if a.isdisjoint(b):
    A = min(a)
    B = min(b)
    if A > B:
        ans = B + A
    else:
        ans = A + B
else:
    c = a & b
    ans = min(c)
print(ans)