import sys input = sys.stdin.readline A=input() S=input() ANS="" for s in S: if 48<=ord(s)<=57: ANS+=A[int(s)] else: ANS+=s print(ANS)