#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, m;
  string A, B;
  cin >> n >> m >> A >> B;
  A = '@' + A;
  B = '@' + B;
  vector<vector<int>> dp(n + 1, vector<int>(m + 1));
  int ans = -2e9;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (A[i] == B[j])
        dp[i][j] = dp[i - 1][j - 1] + 2;
      else
        dp[i][j] = max(max(dp[i - 1][j], dp[i][j - 1]) - 1, 0);
      ans = max(ans, dp[i][j]);
    }
  }
  cout << ans;
}
