#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
    // Your code here!
    string S1, S2;
    cin >> S1 >> S2;
    
    int dp[1001][1001];
    
    dp[0][0] = 0;
    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 = 0; i < S1.size(); i++){
        for(int j = 0; j < S2.size(); j++){
            dp[i+1][j+1] = min(dp[i+1][j]+1, dp[i][j+1]+1);
            if(S1[i] == S2[j]) dp[i+1][j+1] = min(dp[i][j], dp[i+1][j+1]);
            else dp[i+1][j+1] = min(dp[i][j]+1, dp[i+1][j+1]);
        }
    }
    
    cout << dp[S1.size()][S2.size()] << endl;
    return 0;
}

