#include <iostream>
#include<vector>
using namespace std;

int GetMinDistance(string s1, string s2) {
    if (s1.empty()|| s2.empty())
        return max(s1.size(), s2.size());
    int len1 = s1.size();
    int len2 = s2.size();
    vector<vector<int>> f(len1 + 1, vector<int>(len2 + 1, 0));
    for (int i = 0; i <= len1; ++i)
        f[i][0] = i;
    for (int j = 0; j <= len2; ++j)
        f[0][j] = j;
    for (int i = 1; i <= len1; ++i) {
        for (int j = 1; j <= len2; ++j) {
            if (s1[i - 1] == s2[j - 1]) {
                f[i][j] = min(f[i - 1][j], f[i][j - 1]) + 1;
                f[i][j] = min(f[i - 1][j - 1], f[i][j]);
            } else {
                f[i][j] = min(f[i - 1][j], f[i][j - 1]) + 1;
                f[i][j] = min(f[i - 1][j - 1]+1, f[i][j]);
            }
        }

    }
    return f[len1][len2];
}

int main() {
    string a, b;
    while (cin >> a >> b) { // 注意 while 处理多个 case
        cout <<GetMinDistance(a,b) << endl;
    }
    return 0;
}
// 64 位输出请用 printf("%lld")