#define _USE_MATH_DEFINES #include #include #include #include #include #include //#include #include #include #include #include #include #include ///////// #define REP(i, x, n) for(int i = x; i < n; i++) #define rep(i,n) REP(i,0,n) #define P(p) cout<<(p)< ///////// typedef long long LL; typedef long double LD; ///////// using namespace::std; ///////// const int LenMax = 1001; int dp[LenMax][LenMax]; int LCS(string A,string B){ int aLen = A.size(); int bLen = B.size(); for(int i = 0; i < aLen; ++i){ dp[i][0] = 0; } for(int j = 0; j < bLen; ++j){ dp[0][j] = 0; } for(int i = 1; i <= aLen; ++i){ for(int j = 1; j <= bLen; ++j){ if( A[i-1] == B[j-1] ){ dp[i][j] = dp[i-1][j-1] + 1; }else{ dp[i][j] = max( dp[i][j-1],dp[i-1][j-1] ); } } } return dp[aLen][bLen]; } int main(void){ std::cin.tie(0); std::ios::sync_with_stdio(false); std::cout << std::fixed;// //cout << setprecision(16);// int n,m; string S,T; cin>>n>>m>>S>>T; int Len; Len = LCS(S,T); int ans; if( S.size() > T.size() ){ ans = S.size() - Len; }else{ ans = T.size() - Len; } P(ans); return 0; }