#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

int dp[1010][1010];

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);

    string s1,s2;
    cin>>s1>>s2;
    for(int i=0;i<=s1.size();i++)dp[i][0]=i;
    for(int j=0;j<=s2.size();j++)dp[0][j]=j;
    for(int i=1;i<=s1.size();i++){
        for(int j=1;j<=s2.size();j++){
            if(s1[i-1]==s2[j-1])dp[i][j]=min(dp[i-1][j-1],min(dp[i-1][j]+1,dp[i][j-1]+1));
            else dp[i][j]=min(dp[i-1][j-1]+1,min(dp[i-1][j]+1,dp[i][j-1]+1));
        }
    }
    cout<<dp[s1.size()][s2.size()]<<endl;

}
