#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=5e3+5;
int dp[N][N];
int lcs(string s1,string s2)
{
int n=s1.size();
int mx=0;
for(int a=0;a<n;a++){
int sum=0;
int c=a;
for(int b=0;b<n;b++){
if(s1[c]==s2[b]){
c++;
sum++;
}
}
mx=max(mx,sum);
}
return mx;
}
signed main()
{
freopen("ANAGRAM.INP","r",stdin);
freopen("ANAGRAM.OUT","w",stdout);
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
string s,t;
cin>>s>>t;
int n=s.size();
cout<<n-lcs(s,t);
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKI2RlZmluZSBpbnQgbG9uZyBsb25nCmNvbnN0IGludCBOPTVlMys1OwppbnQgZHBbTl1bTl07CmludCBsY3Moc3RyaW5nIHMxLHN0cmluZyBzMikKewogICAgaW50IG49czEuc2l6ZSgpOwogICAgaW50IG14PTA7CiAgICBmb3IoaW50IGE9MDthPG47YSsrKXsKICAgICAgICBpbnQgc3VtPTA7CiAgICAgICAgaW50IGM9YTsKICAgICAgICBmb3IoaW50IGI9MDtiPG47YisrKXsKICAgICAgICAgICAgaWYoczFbY109PXMyW2JdKXsKICAgICAgICAgICAgICAgIGMrKzsKICAgICAgICAgICAgICAgIHN1bSsrOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIG14PW1heChteCxzdW0pOwogICAgfQogICAgcmV0dXJuIG14Owp9CnNpZ25lZCBtYWluKCkKewogICAgZnJlb3BlbigiQU5BR1JBTS5JTlAiLCJyIixzdGRpbik7CiAgICBmcmVvcGVuKCJBTkFHUkFNLk9VVCIsInciLHN0ZG91dCk7CiAgICBpb3NfYmFzZTo6c3luY193aXRoX3N0ZGlvKGZhbHNlKTsKICAgIGNpbi50aWUoMCk7CiAgICBjb3V0LnRpZSgwKTsKICAgIHN0cmluZyBzLHQ7CiAgICBjaW4+PnM+PnQ7CiAgICBpbnQgbj1zLnNpemUoKTsKICAgIGNvdXQ8PG4tbGNzKHMsdCk7Cn0K