#include <iostream>
#include <unordered_set>
using namespace std;

int main() {
    string encrypt;
    getline(cin, encrypt);
    string text;
    getline(cin, text);
    string mode = "";
    unordered_set<char> mark;
    for(char& c : encrypt){
        if(!mark.count(c)){
            mode += c;
            mark.emplace(c);
        }
    }
    for(int i=0; i<27; ++i){
        char c = 'a' + i;
        if(!mark.count(c)){
            mode += c;
            mark.emplace(c);
        }
    }

    for(char& c : text){
        cout << mode[c-'a'];
    }
    return 0;
}
// 64 位输出请用 printf("%lld")