table0= ['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']
def jiami(mishi,mingma):
#实现去重
list =sorted(set(mishi),key=mishi.index) #set去重了但是无序,按照原来的顺序排序
#添加剩余字母,生成完整的新字母表
table= ['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']
s_low = []
for i in list:
s_low.append(i.lower())
if i.lower() in table:
table.remove(i.lower()) #remove会改变原来的table
new_table = s_low + table
#输入明文
out = str()
for c in mingma:
if c.isupper() == True:
index = table0.index(c.lower())
out += new_table[index].upper()
else:
index = table0.index(c)
out += new_table[index]
print(out)
mishi = list(input())
mingma = input()
jiami(mishi,mingma)