A = input().strip() S = input().strip() txt = ''.join([A[eval(i)] if i.isdecimal() else i for i in S]) print(txt)