Link to this code: https://cses.fi/paste/74d9aae48a77d94a2869c0/
/*
  author: @ankingcodes
  created: 2021-08-08 09:06:36.673565
*/
        
#include<bits/stdc++.h>
#include<algorithm>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define INF 1e18
#define f first
#define s second
#define mp make_pair
#define pb push_back
const int MOD = (int) 1e9 + 7;

typedef tree<int, null_type, less<int>, rb_tree_tag,
                tree_order_statistics_node_update> PBDS;

typedef tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag,
                tree_order_statistics_node_update> pairPBDS;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string a, b; cin >> a >> b; 
  int szA = a.size(), szB = b.size();
  int dp[szA+1][szB+1];
  memset(dp, MOD, sizeof dp);	
  dp[0][0] = 0;
  for (int i=0;i<=szA;i++) {
    for (int j=0;j<=szB;j++) {
      if (i) dp[i][j] = min(dp[i][j], dp[i-1][j]+1);
      if (j) dp[i][j] = min(dp[i][j], dp[i][j-1]+1);
      if (i && j) dp[i][j] = min(dp[i][j], dp[i-1][j-1] + (a[i-1]!=b[j-1]));
    }
  }
  cout << dp[szA][szB] << endl;
  return 0;
}