#include<iostream>
#include<string>
#include<math.h>
#include<algorithm>
#include<vector>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
int main(){
    int dp[1001][1001];
    string x,y;
    cin>>x>>y;
    rep(j,x.size()+1) rep(k,y.size()+1) dp[j][k]=max(j,k);
    rep(j,x.size()) rep(k,y.size()){
        if(x[j]==y[k]) dp[j+1][k+1]=min(dp[j][k],min(dp[j+1][k]+1,min(dp[j][k+1]+1,dp[j][k]+1)));
        else dp[j+1][k+1]=min(dp[j+1][k]+1,min(dp[j][k+1]+1,dp[j][k]+1));
    }
    cout<<dp[x.size()][y.size()]<<endl;
}
