def main(): A = input() S = input() #print(A) #print(S) word = '' for s in S: if s.isdigit(): word += A[int(s)] else: word += s print(word) if __name__ == '__main__': main()