// AOJ DPL_1_E Edit Distance (Levenshtein Distance)
// 2018.4.26 bal4u

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

#define MAX_S 1003
char s1[MAX_S], s2[MAX_S];
int M[MAX_S][MAX_S];

int string_distance(int len1, char *str1, int len2, char *str2)
{
    int  i, j, d, min;

    if (len1 == 0) return len2;
    if (len2 == 0) return len1;

    for (j = 0; j <= len1; j++) M[j][0] = j;
    for (i = 0; i <= len2; i++) M[0][i] = i;
    for (j = 1; j <= len1; j++) {
        for (i = 1; i <= len2; i++) {
            d = (str1[j-1] != str2[i-1]);
            min =     M[j-1][i  ] + 1;
            if (min > M[j  ][i-1] + 1) min = M[j  ][i-1] + 1;
            if (min > M[j-1][i-1] + d) min = M[j-1][i-1] + d;
            M[j][i] = min;
        }
    }
    return M[len1][len2];
}

int main()
{
	int w1, w2;
	char *p;

	fgets(p=s1, MAX_S, stdin);
	while (*p > ' ') p++; *p = 0; w1 = p-s1;
	fgets(p=s2, MAX_S, stdin);
	while (*p > ' ') p++; *p = 0; w2 = p-s2;
	printf("%d\n", string_distance(w1, s1, w2, s2));
	return 0;
}

