A = input().strip() S = input().strip() result = [] for c in S: if c.isdigit(): result.append(A[int(c)]) else: result.append(c) print(''.join(result))