#include <iostream>
#include <vector>
#include <string>
using namespace std;
int calStringDistance (string A, string B)
{
int n=(int)A.si***t)B.size();
vector<vector<int>> dp(n+1,vector<int>(m+1,0));
dp[0][0]=0;
for(int i=1;i<=m;i++) dp[0][i]=i;
for(int i=1;i<=n;i++) dp[i][0]=i;
for(int i=1;i<=n;i++){
for (int j=1; j<=m; ++j) {
int one = dp[i-1][j] +1,two = dp[i][j-1]+1,three = dp[i-1][j-1];
if(A[i-1]!=B[j-1]) three+=1;
dp[i][j] = min(min(one,two),three);
}
}
return dp[n][m];
}
int main(){
string a,b;
while(cin >> a >> b){
cout << calStringDistance (a, b) <<endl;
}
return 0;
}
//大神的解法,不过还没完全看懂,先记下来