#include<iostream>
#include<vector>
using namespace std;
int main()
{
string word1,word2;
while(cin>>word1>>word2)
{
int m=word1.size();
int n=word2.size();
vector<vector<int>>dp(m+1,vector<int>(n+1,0));
for(int i=0;i<m+1;i++)dp[i][0]=i;
for(int j=0;j<n+1;j++)dp[0][j]=j;
for(int i=1;i<m+1;i++)
{
for(int j=1;j<n+1;j++)
{
int v=0;
if(word1[i-1]!=word2[j-1])
{
v=1;
}
dp[i][j]=min(min(dp[i-1][j]+1,dp[i][j-1]+1),dp[i-1][j-1]+v);
}
}
cout<<dp[m][n]<<endl;
}
return 0;
}