#include<iostream>
#include<string>
#include<cstring>
#include<vector>
#include<unordered_set>
using namespace std;

const int N = 105;
int h[26];
char th[26];

vector<char> v;
unordered_set<char> us;


int main() {
    string s, m;
    cin >> s;
    cin >> m;

    for (char c : s) {
        h[c - 'a']++;
        if (us.count(c) == 0) {
            us.insert(c);
            v.push_back(c);
        } 
    }

    string left = "", res = "";
    for (auto it = v.begin(); it != v.end(); it ++) res += *it;

    for (int i = 0; i < 26; i++) {
        if (!h[i]) left += i + 'a';
    }
    res += left;

    int cnt = 0;
    for (char c : res) {
        th[cnt++] = c;
    }
    for (char c : m) {
        cout << th[c - 'a'];
    }

    return 0;
}