#include using namespace std; using ll = long long; int main(){ string S, T; cin >> S >> T; for (auto x : T){ if ('0' <= x && x <= '9') cout << S[x-'0']; else cout << x; } cout << endl; return 0; }