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

int main() {
    string S1, S2;
    cin >> S1 >> S2;
    int N = S1.size(), M = S2.size(), dp[1100][1100];
    memset(dp, 0, sizeof(dp));
    S1 = ' ' + S1, S2 = ' ' + S2;
    for (int i = 0; i <= N; ++i) dp[i][0] = i;
    for (int j = 0; j <= M; ++j) dp[0][j] = j;
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < M; ++j) {
            int t = S1[i + 1] != S2[j + 1] ? 1 : 0;
            dp[i + 1][j + 1] = min(dp[i][j] + t, min(dp[i + 1][j] + 1, dp[i][j + 1] + 1));
        }
    }
    cout << dp[N][M] << endl;
    
    return 0;
}
