import std.stdio, std.string, std.conv, std.algorithm, std.numeric;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;

void main() {
    string s, t;
    scan(s);
    scan(t);

    int n = s.length.to!int, m = t.length.to!int;

    auto dp = new int[][](n + 1, m + 1);
    foreach (i ; 1 .. n + 1) {
        dp[i][0] = i;
    }
    foreach (j ; 1 .. m + 1) {
        dp[0][j] = j;
    }

    foreach (i ; 1 .. n + 1) {
        foreach (j ; 1 .. m + 1) {
            dp[i][j] = min(dp[i-1][j] + 1, dp[i][j-1] + 1, dp[i-1][j-1] + (s[i-1] != t[j-1]));
        }
    }

    writeln(dp[n][m]);
}


void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}