#pragma GCC optimize("02")
#include
using namespace std;
void start()
{
freopen("KiTuChung.inp","r",stdin);
freopen("KiTuChung.out","w",stdout);
ios::sync_with_stdio(0);
cin.tie(0),cout.tie(0);
}
int main() {
start();
string x, y;
cin >>x>>y;
set kt;
for (char c : x) {
if (y.find(c) != string::npos) {
kt.insert(c);
}
}
for (char c : kt) {
cout << c << std::endl;
}
}