import strutils

var a, s = readLine stdin

for i in 0 .. s.len.pred:
  if isDigit s[i]:
    s[i] = a[s[i].ord.pred 48]

echo s