#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <string>
#include <string.h>

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

using namespace std;
int dp[1001][1001];//dp[y][x];
//??????????????????
string x,y;
void solve(){
		cin >> x >> y ;
		memset(dp,10000,1001*1001);
		REP(i,x.size()+1){
			  dp[0][i] = i;
		}
		REP(i,y.size()+1){
			  dp[i][0] = i;
		}
		FOR(i,1,x.size()+1){
			FOR(j,1,y.size()+1){
				if(x[i-1]==y[j-1]){
					dp[j][i] = dp[j-1][i-1];
				}
				else {
					dp[j][i] = min ( 1 + min(dp[j-1][i],dp[j][i-1]),dp[j-1][i-1]+1);
				}

			}
		}
		/*REP(i,y.size()+1){
			REP(j,x.size()+1){
				cout << dp[i][j] << " ";
			}
			cout << endl;
		}
		*/
		cout << dp[y.size()][x.size()] << endl;
}


int main(){
solve();
}
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
#include <climits>

using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int MAX_N=55555;
bool is_prime[MAX_N];
int prime[MAX_N];
int main(){
  int dp[1001][1001];
  for(int nn=0;nn<1;nn++){
    string s1,s2;
    cin>>s1>>s2;
    for(int i=0;i<1001;i++)fill(dp[i],dp[i]+1001,0);
    for(int i=0;i<s1.size()+1;i++)dp[i][0]=i;
    for(int i=0;i<s2.size()+1;i++)dp[0][i]=i;
    for(int i=0;i<s1.size();i++){
      for(int j=0;j<s2.size();j++){
        int x=1;
        if(s1[i]==s2[j]) x=0;
        dp[i+1][j+1]=min(dp[i][j]+x,min(dp[i][j+1]+1,dp[i+1][j]+1));
      }
    }
    cout<<dp[s1.size()][s2.size()]<<endl;
  }
  return 0;
}

