#include // #include using namespace std; // using namespace atcoder; using ll = long long; using ull = unsigned long long; using P = pair; #define rep(i,n) for(ll i = 0;i < (ll)n;i++) #define ALL(x) (x).begin(),(x).end() #define MOD 1000000007 int main(){ string a,s; cin >> a >> s; rep(i,s.size())if('0' <= s[i] && s[i] <= '9')s[i] = a[s[i]-'0']; cout << s << "\n"; return 0; }