#include <bits/stdc++.h>
using namespace std;
int main() {
  long long tc = 1;
  while (tc--) {
    long long n, m;
    scanf("%lld%lld", &n, &m);
    long long dp[n + 1][m + 1];
    char s[n + 1], k[m + 1];
    scanf("%s%s", s + 1, k + 1);
    long long ans = 0;
    for (long long i = 0; i <= n; ++i)
      for (long long j = 0; j <= m; ++j) 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, dp[i - 1][j] - 1, dp[i][j - 1] - 1});
        if (s[i] == k[j]) dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + 2);
        ans = max(ans, dp[i][j]);
      }
    printf("%lld\n", ans);
  }
}
