#include <bits/stdc++.h>
using namespace std;
long long int dx[] = {0, 1, 0, -1, -1, 1, -1, 1};
long long int dy[] = {-1, 0, 1, 0, -1, 1, 1, -1};
const long long int MAXN = 2e5 + 5;
const long long int N = 2e5 + 5;
long long int n, m;
void LCSubsequence(string s1, string s2) {
  long long int n1 = s1.size(), n2 = s2.size();
  vector<vector<long long int>> dp(n1 + 1, vector<long long int>(n2 + 1, 0));
  long long int res = 0;
  for (long long int i = 0; i <= n1; i++) {
    for (long long int j = 0; j <= n2; j++) {
      if (i == 0 || j == 0) {
        dp[i][j] = 0;
      } else if (s1[i - 1] == s2[j - 1]) {
        dp[i][j] = dp[i - 1][j - 1] + (4 - 2);
      } else {
        dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]) - 1;
      }
      if (dp[i][j] < 0) dp[i][j] = 0;
      res = max(res, dp[i][j]);
    }
  }
  cout << res << "\n";
}
long long int goAns = 0;
long long int go(long long int i, long long int j, string s1, string s2) {
  if (i >= n || j >= m) return 0;
  long long int x = 0, y = 0, res = 0;
  if (s1[i] == s2[j]) {
    res = (4 - 2) + max(0LL, go(i + 1, j + 1, s1, s2));
  } else {
    x = -1 + go(i + 1, j, s1, s2);
    y = -1 + go(i, j + 1, s1, s2);
    res = max({0LL, x, y});
  }
  goAns = max(goAns, res);
  return res;
}
void solve() {
  long long int x, y, z;
  cin >> n >> m;
  string s1, s2;
  cin >> s1 >> s2;
  LCSubsequence(s1, s2);
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int T = 1;
  while (T--) solve();
  return 0;
}
