a = input() b = input() c = "" for i in b: if i in "0123456789": c += a[int(b)] else: c += i print(c)