#include <bits/stdc++.h>
using namespace std;
const double p = 3.1415926535897932384;
long long mod = 100000000;
signed main() {
  long long n, m;
  cin >> n >> m;
  string s1, s2;
  cin >> s1;
  cin >> s2;
  long long ans = 0;
  long long dp[n + 1][m + 1];
  for (long long i = 0; i <= n; i++) {
    for (long long j = 0; j <= m; j++) {
      if (i == 0 || j == 0) {
        dp[i][j] = 0;
      }
    }
  }
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= m; j++) {
      dp[i][j] = max(0ll, max(dp[i - 1][j], dp[i][j - 1]) - 1);
      if (s1[i - 1] == s2[j - 1]) {
        dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + 2);
      }
      ans = max(ans, dp[i][j]);
    }
  }
  cout << ans << endl;
}
