#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main() {
string key, str;
while (cin >> key >> str) {
// true代表未出现过
string new_key;
vector<bool> flag(26,true);
// 对密钥key去重,生成短密钥new_key
for (auto &i:key){
i = tolower(i);
if (flag[i - 'a']){
// 一旦出现了,标记为false
flag[i - 'a'] = false;
new_key.push_back(i);
}
}
// 补充密钥,生成字母表
string table = "abcdefghijklmnopqrstuvwxyz";
for (auto &i :table){
if (flag[i - 'a']){
new_key.push_back(i);
}
}
string ciphertext = "";
for (auto &i:str){
ciphertext.push_back(new_key[i - 'a']);
}
cout << ciphertext;
}
return 0;
}