#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int min(int a, int b)
{
    return (a < b ? a : b);
}

int read_file(char *fname, char **buf) // ??????????????? fname, ?????????????????? buf (????????¢??°?????§?????¢????¢????)
{
    int n;
    char *p;
    FILE *fin;

    fin = fopen(fname, "r"); // ?????????????????????????????¢????????§????????????
    if (fin == NULL) { // ??????????????§??????????????°??¨????????????
        printf("cannot open %s\n", fname);
        exit(1);
    }

    fseek(fin, 0, SEEK_END);
    n = ftell(fin); // ??????????????????????????????
    fseek(fin, 0, SEEK_SET);
    p = (char *)malloc(n * sizeof(char)); // ???????????????????´????????????¢???????¢????
    if (p == NULL) {
        printf("not enough memory\n");
        exit(1);
    }

    fread(p, sizeof(char), n, fin); // ?????¢??? p ??? n ??????????????????
    fclose(fin); // ????????????????????????
    *buf = p; // ????????????????´????????????????????????¢??°?????????????????´?????????

    return (n); // ?????????????????????
}

int lehvenstein_distance(int n, int m, char *s, char *t)
{
    int **dp;
    int i, j;
    int ans;

    dp = (int **)malloc(sizeof(int *) * (n + 1));

    for (i = 0; i <= n; i++){
        dp[i] = (int *)malloc(sizeof(int) * (m + 1));
        for (j = 0; j <= m; j++) dp[i][j] = 1001001001;
    }

    for (i = 0; i <= n; i++) dp[i][0] = i;
    for (j = 0; j <= m; j++) dp[0][j] = j;

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

    ans = dp[n - 1][m - 1];

    for (i = 0; i < n; i++) free(dp[i]);
    free(dp);

    return (ans);
}

int main(int argc, char *argv[])
{
    int n, m;
    int c;
    //char *X, *Y;
    char X[1024], Y[1024];

    //if (argc < 3) { // ??????????????????????????°????¶???????????????°??????
    //    printf("%s file1 file2\n", argv[0]); // argv[0] ???????????°??????????????\??£?????????
    //    return (-1);
    //}

    //n = read_file(argv[1], &X); // 1???????????????????????? X ???????????????
    //m = read_file(argv[2], &Y); // 2???????????????????????? Y ???????????????

    //printf("%s %s\n", X, Y);

    scanf("%s", X);
    scanf("%s", Y);

    n = strlen(X) + 1; m = strlen(Y) + 1;

    //X[n - 1] = Y[m - 1] = 0;

    c = lehvenstein_distance(n - 1, m - 1, X, Y); // X ??¨ Y ?????¨????????¢????¨????

    printf("%d\n", c); // ???????????????

    //free(X);
    //free(Y);

    return (0);
}