#include <bits/stdc++.h>
using namespace std;
const int N = 300500;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);
  int n, m;
  cin >> n >> m;
  string a, b;
  cin >> a >> b;
  int dp[n + 1][m + 1];
  int ans = 0;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= m; j++) {
      if (i == 0 || j == 0) {
        dp[i][j] = 0;
      } else {
        if (a[i - 1] == b[j - 1]) {
          dp[i][j] = dp[i - 1][j - 1] + 2;
        } else {
          dp[i][j] = max(0, max(dp[i - 1][j], dp[i][j - 1]) - 1);
        }
      }
      ans = max(ans, dp[i][j]);
    }
  }
  cout << ans << endl;
  return 0;
}
