#include <bits/stdc++.h>
bool flag = true;
using namespace std;
const double epsilon = 0.0000001f;
const double PI = 3.141592653589793238460;
const long long int cons = 2e5 + 1;
const long long int inf = 998244353;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int T = 1, te = 1;
  while (T--) {
    long long int i = 0, j = 0, ans = 0, x = 0, y = 0, z = 0;
    long long int n, k = 0, m = 0, mn = INT_MAX, mx = INT_MIN;
    cin >> n >> m;
    long long int dp[n + 1][m + 1];
    memset(dp, 0, sizeof(dp));
    string a, b;
    cin >> a >> b;
    for (i = 1; i <= n; i++) {
      for (j = 1; j <= m; j++) {
        if (a[i - 1] != b[j - 1]) {
          dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]) - 1;
          dp[i][j] = max(0ll, dp[i][j]);
        } else {
          dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + 2);
        }
        ans = max(ans, dp[i][j]);
      }
    }
    cout << ans << endl;
  }
  return 0;
}
