#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int dp[1001][1001];




	
int main (){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	//input
	string s,t;
	cin >> s >> t;

	//set
	for(int i=0;i<=s.size();++i)dp[i][0]=i;
	for(int i=0;i<=t.size();++i)dp[0][i]=i;

	//algorithm
	for(int i=1;i<=s.size();++i)for(int j=1;j<=t.size();++j){
		if(s[i-1]==t[j-1])dp[i][j]=dp[i-1][j-1];
		else dp[i][j]=min(dp[i-1][j],min(dp[i][j-1],dp[i-1][j-1]))+1;
	}

	//output
	//for(int i=0;i<=s.size();++i){for(int j=0;j<=t.size();++j)cout << dp[i][j];cout << endl;}
	cout << dp[s.size()][t.size()] << endl;
}



