A = input()
S = input()
ans = ""

for i in S:
	if str.isdigit(i) == True:	#数字ならTrueを返す関数
		i = int(i)
		ans += A[i]
	else:
		ans += i

print(ans)