key = input()
s = input()

d = dict()
i = 0
for ch in key:
    if ch not in d.values():
        d[chr(ord('a') + i)] = ch
        i += 1

# 将新建立的字母表中未出现的字母按照正常字母表顺序加入新字母表
j = 0
while i < 26:
    while chr(ord('a') + j) in d.values():
        j += 1
    d[chr(ord('a') + i)] = chr(ord('a') + j)
    i += 1
for ch in s:
    print(d[ch], end='')