A=input() S=input() B=[c if c>'9' else A[ord(c)-48] for c in S] print("".join(B))