A = input() S = input() T = '' for i in range(len(S)): if S[i].isdecimal(): T += A[int(S[i])] else: T += S[i] print(T)