#include using namespace std; int main() { int n,m; cin >> n >> m; string S,T; cin >> S >> T; int MAX = max(n,m); int INF = 100000000; vector>dp(MAX+1,vector(m+1,INF)); dp[0][0] = 0; for(int i = 1; i <= n; i++) { for(int j = 1; j <= m; j++) { if(S[i-1] == T[j-1]) dp[i][j] = min(dp[i-1][j-1],dp[i][j]); else dp[i][j] = min(dp[i][j],min(dp[i-1][j-1]+1,min(dp[i-1][j] + 1,dp[i][j-1] + 1))); } } cout << dp[n][m]; }