import sys input = sys.stdin.readline A = list(input())[: -1] S = list(input())[: -1] for i in range(len(S)): try: S[i] = A[int(S[i])] except: continue print("".join(S))