//cpp:
#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
string a, b;
cin >> a >> b;
int j = 0;
set<char> s;
for (int i = 0; i < b.length(); i++) {
while (a[j] != b[i]) {
if(s.find(toupper(a[j]))==s.end())
printf("%c", toupper(a[j]));
s.insert(toupper(a[j]));
//cout << a[j];
j++;
}
j++;
//cout << "++++" << b[i] << endl;
}
while (j < a.length()) {
if (s.find(toupper(a[j])) == s.end())
printf("%c", toupper(a[j]));
s.insert(toupper(a[j]));
//cout << a[j];
j++;
}
return 0;
}