#include <stdio.h>
#include <string.h>
#define min(p,q)((p)<(q)?(p):(q))

char s[1010],t[1010];
int dp[1010][1010];
int main(){
	scanf("%s%s",s,t);
	int sn=strlen(s);
	int tn=strlen(t);
	for(int i=1;i<=sn;i++)dp[i][0]=i;
	for(int j=1;j<=tn;j++)dp[0][j]=j;
	for(int i=1;i<=sn;i++)for(int j=1;j<=tn;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]));
	printf("%d\n",dp[sn][tn]);
}
