code is below
#include<bits/stdc++.h>
using namespace std;
int main(){
string s1,s2;
getline(cin,s1);
getline(cin,s2);
int l=0,i=0,j=0;
int min=INT_MAX;
string s3;
int start=0;
// cout<<s1.length()<<" “<<s2.length()<<”\n";
while(i<s1.length()){
if(s1[i]==s2[0]){
l=0;
}
if(s1[i]==s2[j]){
// cout<<s2[j]<<" “<<i<<” “<<j<<” “<<l<<” “;
i++;
j++;
l++;
if(j==s2.length()){
// cout<<“yes”;
// cout<<l<<” ";
if(min>l){
min=l;
start=i-l;
}
j=0;
}
}
else if(s1[i]!=s2[j]){
i++;
l++;
}
}
s3=s1.substr(start,min);
cout<<s3<<"\n";
}