#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
string key;
cin>>key;
string mcode;
cin>>mcode;
vector<char> sc;
for(int i=0;i<key.length();i++){
auto it=find(sc.begin(),sc.end(),key[i]);
// cout<<key[i]<<endl;
if(it==sc.end())
sc.push_back(key[i]);
}
int res[26];for (int i = 0; i < 26; i ++)res[i]=0;
string str1;
for(int j=0;j<sc.size();j++){
res[(sc[j]-'a')]=1;
str1+=sc[j];
}
for(int i=0;i<26;i++){
if(res[i]!=1){
char ch=i+'a';
str1+=ch;
}
}
for(int i=0;i<mcode.size();i++){
cout<<str1[ mcode[i]-'a'];
}
}
// 64 位输出请用 printf("%lld")