#include<bits/stdc++.h>
using namespace std;
string a,b;
string a1,b1;
int f[2004][2004];
int l1,l2,c;
int dp(int x,int y)
{
if(f[x][y]!=0)
return f[x][y];
if(x==0)
return f[x][y]=y;
if(y==0)
return f[x][y]=x;
c=1;
if(a1[x]==b1[y])
c=0;
return f[x][y]=min(min(dp(x-1,y)+1,dp(x,y-1)+1),dp(x-1,y-1)+c);
}
int main()
{
cin>>a;
cin>>b;
l1=a.size();
l2=b.size();
a1=' '+a;
b1=' '+b;
dp(l1,l2);
cout<<f[l1][l2];
}