a=list(input()) s=input() ans='' for v in s: if not v.isnumeric(): ans+=v else: ans+=a[int(v)] print(ans)