#include<stdio.h>
#include<string.h>
char s1[1001], s2[1001];
int s1_l,s2_l,i,j;
int min (int a, int b, int c);
int main(){
    scanf("%s",&s1[1]);
    scanf("%s",&s2[1]);
    s1_l = strlen(s1+1), s2_l = strlen(s2+1);   //s1, s2?????????????±??????????
    int L[s1_l+1][s2_l+1];  //???????¨???????????§???????
    for (j = 0; j <= s2_l; j ++) {
        L[0][j] = j;
    }
    for (i = 1; i <= s1_l; i ++) {
        for (j = 0; j <= s2_l; j ++) {
            L[i][j] = min (
                    L[i-1][j] + 1,
                    L[i-1][j-1] + !(s1[i] == s2[j]),
                    L[i][j-1] + 1
                    );
        }
    }
    printf("%d", L[s1_l][s2_l]);
    return 0;
}
int min (int a, int b, int c) {
    if (a > b) {
        if (b > c) return c;
                   return b;
    } else {
        if (a > c) return c;
                   return a;
    }
};