import sys input = lambda : sys.stdin.readline().rstrip() sys.setrecursionlimit(2*10**5+10) write = lambda x: sys.stdout.write(x+"\n") _print = lambda *x: print(*x, file=sys.stderr) a = input() s = input() d = {} for i in range(10): d[str(i)] = a[i] ans = [] for c in s: if c in d: c = d[c] ans.append(c) print("".join(ans))