#include <bits/stdc++.h>
using namespace std;
long long kiran_bhanushali[29][7][20];
void init() {
  for (long long i = 0; i < 29; i++) {
    kiran_bhanushali[i][0][0] = rand() % 1000;
  }
}
void solve() {
  long long n, m;
  cin >> n >> m;
  string s, t;
  cin >> s >> t;
  long long dp[n + 1][m + 1];
  for (long long i = 0; i <= n; i++)
    for (long long j = 0; j <= m; j++) dp[i][j] = 0;
  long long ans = 0;
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= m; j++) {
      if (s[i - 1] == t[j - 1]) {
        dp[i][j] = max((long long)0, 2 + dp[i - 1][j - 1]);
      } else {
        dp[i][j] = max({(long long)0, dp[i - 1][j] - 1, dp[i][j - 1] - 1});
      }
      ans = max(ans, dp[i][j]);
    }
  }
  cout << ans << endl;
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  init();
  long long t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
