#include<stdio.h>
#include<string.h>
#define min(a,b)(a)<(b)?(a):(b)
 
char s[1005],t[1005];
int n,m,x,i,j;
int dp[1005][1005]={0};
 
int main()
{
    s[0]=t[0]=' ';
    gets(s+1);
    gets(t+1);
    n=strlen(s),m=strlen(t);
    for(i=0;i<=(n<m?m:n);i++)
        dp[i][0]=dp[0][i]=i;
    for(i=1;i<=n;i++)
        for(j=1;j<=m;j++)
            dp[i][j]=min(min(dp[i-1][j]+1,dp[i][j-1]+1),dp[i-1][j-1]+(s[i-1]==t[j-1]?0:1));
    printf( "%d\n",(dp[n][m]));
    return 0;
}