a = list(input())
s = input()
for i in range(10):
    s = s.replace(str(i), a[i])
print(s)