// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;



#define rep(i,x,y) for(int i=(x);i<(y);++i)

#define mp(a,b) make_pair((a),(b))

#define debug(x) #x << "=" << (x)

 

#ifdef DEBUG

#define _GLIBCXX_DEBUG

#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl

#else

#define dump(x)

#endif



typedef long long int ll;

typedef pair<int,int> pii;

//template<typename T> using vec=std::vector<T>;



const int INF=1<<30;

const long long int INFLL=1LL<<58;

const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};



template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){

	os << "[";

	for (const auto &v : vec) {

		os << v << ",";

	}

	os << "]";

	return os;

}



void solve(){

    string a,b;

    cin >> a >> b;

    

    static int dp[1001][1001];

    fill_n((int*)dp,1001*1001,INF);



    rep(i,0,a.size()+1) dp[i][0]=i;

    rep(j,0,b.size()+1) dp[0][j]=j;



    rep(i,1,a.size()+1){

        rep(j,1,b.size()+1){

            int cost=!(a[i-1]==b[j-1]);

            dp[i][j]=min({dp[i-1][j]+1,dp[i][j-1]+1,dp[i-1][j-1]+cost});

        }

    }

    

    cout << dp[a.size()][b.size()] << endl;

}



int main(){

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	solve();

	return 0;

}

// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

using namespace std;



#define rep(i,x,y) for(int i=(x);i<(y);++i)

#define debug(x) #x << "=" << (x)



#ifdef DEBUG

#define _GLIBCXX_DEBUG

#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl

#else

#define print(x)

#endif



const int inf=1e9;

const int64_t inf64=1e18;

const double eps=1e-9;



template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){

    os << "[";

    for (const auto &v : vec) {

    	os << v << ",";

    }

    os << "]";

    return os;

}



int levenshtein_distance(const std::string &s,const std::string &t){

    std::vector<std::vector<int>> dp(s.size()+1,vector<int>(t.size()+1,s.size()+t.size()));

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

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

    for(int i=1; i<=s.size(); ++i){

        for(int j=1; j<=t.size(); ++j){

            int cost=s[i-1]==t[j-1]?0:1;

            dp[i][j]=min(dp[i-1][j-1]+cost,min(dp[i-1][j],dp[i][j-1])+1);

        }

    }

    return dp[s.size()][t.size()];

}



void solve(){

    string s1,s2;

    cin >> s1 >> s2;

    cout << levenshtein_distance(s1,s2) << endl;

}



int main(){

    std::cin.tie(0);

    std::ios::sync_with_stdio(false);

    cout.setf(ios::fixed);

    cout.precision(10);

    solve();

    return 0;

}

// Fastest known solution for this problem:
#include<bits/stdc++.h>

using namespace std;

#define int long long

int editDistance(string x,string y){

  int n=x.length(),m=y.length();

  int INF=1LL<<55LL;

  vector<vector<int> > dp(n+1,vector<int>(m+1,INF));

  for(int i=0;i<=n;i++) dp[i][0]=i;

  for(int i=0;i<=m;i++) dp[0][i]=i;

  for(int i=1;i<=n;i++){

    for(int j=1;j<=m;j++){

      dp[i][j]=min(dp[i][j],dp[i-1][j]+1);

      dp[i][j]=min(dp[i][j],dp[i][j-1]+1);

      dp[i][j]=min(dp[i][j],dp[i-1][j-1]+(x[i-1]!=y[j-1]));

    }

  }

  return dp[n][m];

}

signed main(){

  string s1,s2;

  cin>>s1>>s2;

  cout<<editDistance(s1,s2)<<endl;

  return 0;

}