#include <bits/stdc++.h>
using namespace std;
void max_self(int &a, int b) { a = max(a, b); }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int N, M;
  string s, t;
  cin >> N >> M >> s >> t;
  vector<vector<int>> dp(N + 1, vector<int>(M + 1));
  int best = 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] = max(0, dp[i - 1][j - 1] + 2);
      else
        dp[i][j] = max(0, max(dp[i - 1][j], dp[i][j - 1]) - 1);
      max_self(best, dp[i][j]);
    }
  cout << best;
}
