#include <algorithm>
#include <iostream>
#include <unordered_map>
using namespace std;
string origin_alphabeta = "abcdefghijklmnopqrstuvwxyz";
string ProcessString(const string &s){
string temp_str = s;
// 1. 去重 采用hashmap
unordered_map<char, int> map;
string ss; // 保存去重后的字符串
for (char & ch : temp_str) {
if (map.find(ch) != map.end()) {
continue;
} else {
map[ch] ++;
ss += ch;
}
}
// 2. 补充未出现的字母
string diff_str;
for (char & ch_alphabeta : origin_alphabeta) {
if (ss.find(ch_alphabeta) != ss.npos) {
continue;
} else {
diff_str += ch_alphabeta;
}
}
sort(diff_str.begin(), diff_str.end());
// 3. 组合新的密码表
return ss + diff_str;
}
string ProcessCode(const string& new_alphabeta, const string & t)
{
string res;
string temp_t = t;
for (char i : temp_t) {
int pos = origin_alphabeta.find(i);
res += new_alphabeta[pos];
}
return res;
}
int main() {
string s, t;
cin >> s >> t;
// 1. 处理字符串s
string new_alphabeta = ProcessString(s);
// 2. 输出加密后的密文
string code = ProcessCode(new_alphabeta, t);
cout << code << endl;
// while (cin >> a >> b) { // 注意 while 处理多个 case
// cout << a + b << endl;
// }
return 0;
}
// 64 位输出请用 printf("%lld")