A = list(input()) S = list(input()) ans = "" for s in S: if not s.isdigit(): ans += s else: s = int(s) ans += A[s] print(ans)