#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  string a, b;
  cin >> a >> b;
  a = a + "#";
  b = b + "#";
  vector<vector<int>> dp(n + 1, vector<int>(m + 1, 0));
  dp[n][m] = -n - m;
  for (int i = 0; i < n; ++i) {
    dp[i][m] = -i - m;
  }
  for (int j = 0; j < m; ++j) {
    dp[n][j] = -j - n;
  }
  for (int i = n - 1; i >= 0; --i) {
    for (int j = m - 1; j >= 0; --j) {
      if (a[i] == b[j]) {
        dp[i][j] = max({4 + dp[i + 1][j + 1], dp[i + 1][j], dp[i][j + 1]});
      } else {
        dp[i][j] = max({-i - j, dp[i + 1][j], dp[i][j + 1]});
      }
    }
  }
  int res = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      res = max(res, dp[i][j] + i + j);
    }
  }
  cout << res << "\n";
  return 0;
}
