//LCS
#if 0

#endif // 0
#include<iostream>
#define MAX 1010
using namespace std;
int l[MAX][MAX];

int main()
{
    string s1,s2;
    cin>>s1>>s2;
    for(int m=0;m<=s1.size();m++)
        for(int n=0;n<=s2.size();n++)
        {
            if(m==0||n==0)
                l[m][n]=max(m,n);
            else if(s1[m-1]==s2[n-1])
                l[m][n]=l[m-1][n-1];
            else
                l[m][n]=min(min(l[m-1][n-1],l[m-1][n]),l[m][n-1])+1;
        }
    cout<<l[s1.size()][s2.size()]<<endl;
    return 0;
}

