#include <iostream>
#include <algorithm>
#include<math.h>
#include<string>
#include<vector>
#include<ctype.h>
#include<set>
using namespace std;
int main() {
#ifdef LOCAL
freopen("D:\\datain.txt", "r", stdin);
#endif
set<char> s;
string str;
getline(cin,str);
for (int i = 0; i < str.length(); i++) {
s.insert(str[i]);
}
string str1;
cin >> str1;
for (int i = 0; i < str1.length(); i++) {
if (s.find(toupper(str1[i])) == s.end()) {
if (isupper(str1[i])&&s.find('+') != s.end()) {
//printf("%c", tolower(str1[i]));
}
else {
printf("%c", str1[i]);
}
}
}
cout << endl;
}