#include using namespace std; typedef long long ll; typedef pair pll; typedef vector vll; #define r(a, b, c, r, ...) r #define r2(i, a, b) for(ll i = ll(a); i < ll(b); ++i) #define r1(i, b) r2(i, 0, b) #define rep(...) r(__VA_ARGS__, r2, r1)(__VA_ARGS__) const ll INF = 1ll << 60; // 1e18 const ll MOD = 1000000007; int main() { { ll n; cin >> n; cin >> n; } string s, t; cin >> s >> t; vector d(s.size() + 1, vll(t.size() + 1, INF)); d[0][0] = 0; rep(i, -1, s.size()) rep(j, -1, t.size()) { if(i != -1 && j != -1) { if(s[i] == t[j]) d[i + 1][j + 1] = min(d[i + 1][j + 1], d[i][j]); else d[i + 1][j + 1] = min(d[i + 1][j + 1], d[i][j] + 1); } if(i != -1) d[i + 1][j + 1] = min(d[i + 1][j + 1], d[i][j + 1] + 1); // del if(j != -1) d[i + 1][j + 1] = min(d[i + 1][j + 1], d[i + 1][j] + 1); // insert } cout << d[s.size()][t.size()] << endl; }