A = list(input()) S = list(input()) n = len(S) for i in range(n): if ord('0') <= ord(S[i]) <= ord('9'): S[i] = A[int(S[i])] print(''.join(S))