#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int q;
string a, b;
vector<vector<int>> dp(1010, vector<int>(1010, 0));

int main(void){
    
    cin >> a >> b;
    a.insert(a.begin(), ' '), b.insert(b.begin(), ' ');
    
    for(int i = 0; i <= a.size(); ++i) dp[i][0] = i;
    for(int i = 0; i <= b.size(); ++i) dp[0][i] = i;
    
    for(int i = 1; i <= a.size(); ++i){
        for(int j = 1; j <= b.size(); ++j){
            dp[i][j] = min({dp[i - 1][j - 1] + (a[i - 1] == b[j - 1] ? 0 : 1), dp[i - 1][j] + 1, dp[i][j - 1] + 1});
        }
    }
    cout << dp[a.size()][b.size()] << endl;
    
    return 0;
}

