#include "bits/stdc++.h"
using namespace std;

int main() {
    string X, Y;
    cin >> X >> Y;
    int M = X.size(), N = Y.size();
    vector<vector<int>> dp(M + 1, vector<int>(N + 1));
    for (int i = 0; i <= M; i++) dp.at(i).at(0) = i;
    for (int i = 0; i <= N; i++) dp.at(0).at(i) = i;
    for (int i = 0; i < M; i++) {
        for (int j = 0; j < N; j++) {
            int d = dp.at(i).at(j);
            if (X.at(i) != Y.at(j)) d++;
            d = min(d, dp.at(i).at(j + 1) + 1);
            d = min(d, dp.at(i + 1).at(j) + 1);
            dp.at(i + 1).at(j + 1) = d;
        }
    }
    cout << dp.at(M).at(N) << endl;
}
