A = input() s = input() S = [s[i] for i in range(len(s))] for i in range(len(s)): if S[i] in "0123456789": S[i] = A[int(S[i])] print("".join(S))