s=input()
t=input()
l=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']    #26字母表
list_s=[]
num=[]
list_t=[]
for i in s:
    if i not in list_s:
        list_s.append(i)   #用for循环对字符串s去重
for k in l:   #遍历字母表,如果不在字母表中就添加在列表list_s末尾
    if k not in list_s:
        list_s.append(k)   #list_s=['t', 'r', 'a', 'i', 'l', 'b', 'z', 'e', 's', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'm', 'n', 'o', 'p', 'q', 'u', 'v', 'w', 'x', 'y']
for m in t:
    if m in l:   
        num.append(l.index(m)) #遍历字符串t,如果在字母表l中,就找到字母表中关于t的索引,并添加进列表num中 
for n in num:
    list_t.append(list_s[n])   #根据num中的索引找到list_s中相应的字母,并添加进列表list_t中
print(''.join(list_t))