#include<bits/stdc++.h>
using namespace std;
int main()
{
int t,min_len = 10000,ansl = 0,ansr = 0;
string s,p;
cin>>s>>p;
for(int i = 0; i<=s.size()-p.size(); i++)
{
if(s[i] == p[0])
{
t = 1;
for(int j = i+1; j<s.size(); j++)
{
if(j - i == min_len) break;
if(s[j] == p[t]) t++;
if(t == p.size() && j-i <= min_len)
{
ansl = i,ansr = j;
min_len = j-i;
break;
}
}
}
}
for(int i = ansl; i<=ansr; i++) cout<<s[i];
return 0;
}