#include<stdio.h>
#include<string.h>
int min(int, int, int);
int levenshtein(char*, char*);
main()
{
        char s1[1001], s2[1001];
        scanf("%s%*c%s", s1, s2);
        printf("%d\n", levenshtein(s1, s2));
}
int min(int a, int b, int c){
        int mini = a;
        if(mini > b){
                mini = b;
        }
        if(mini > c){
                mini = c;
        }
        return mini;
}
int levenshtein(char *s1, char*s2)
{
        int i, j;
        const int len1 = strlen(s1) + 1, len2 = strlen(s2) + 1;
        int dp[len1][len2];
        for(i = 0; i < len1; i++){
                dp[i][0] = i;
        }
        for(j = 0; j < len2; j++){
        dp[0][j] = j;
    }
        for(i = 1; i < len1; i++){
                for(j = 1; j < len2; j++){
                        int cost =(s1[i - 1] == s2[j - 1]) ? 0 : 1;
                        dp[i][j] = min(dp[i - 1][j] + 1, dp[i][j - 1] + 1
                                                   , dp[i - 1][j - 1] + cost);
                }
        }
        return dp[len1 - 1][len2 - 1];
}