while True:
try:
dic ={}
s = input()
px = ''
for i in s:
if i not in dic.keys():
dic[i] = 1
else:
dic[i] += 1
for i in s:
if dic[i] > min(dic.values()):
px += i
print(px)
except:
break
try:
dic ={}
s = input()
px = ''
for i in s:
if i not in dic.keys():
dic[i] = 1
else:
dic[i] += 1
for i in s:
if dic[i] > min(dic.values()):
px += i
print(px)
except:
break