#include <bits/stdc++.h>
using namespace std;
void c_p_c() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
long long int n, m;
int32_t main() {
  c_p_c();
  cin >> n >> m;
  string s1, s2;
  cin >> s1 >> s2;
  vector<vector<long long int> > dp(n + 1, vector<long long int>(m + 1));
  for (long long int i = 1; i < (long long int)n + 1; i++) dp[i][0] = -1;
  for (long long int i = 1; i < (long long int)m + 1; i++) dp[0][i] = -1;
  long long int ans = 0;
  for (long long int i = 1; i < (long long int)n + 1; i++) {
    for (long long int j = 1; j < (long long int)m + 1; j++) {
      if (s1[i - 1] == s2[j - 1]) {
        dp[i][j] = max(dp[i - 1][j - 1], 0ll) + 2;
      } else {
        dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]) - 1;
      }
      ans = max(ans, dp[i][j]);
    }
  }
  cout << ans;
  cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC
       << "ms\n";
  return 0;
}
