#include <bits/stdc++.h>
using namespace std;
short dp[405][405][405];
int p[160005], a[405][405], n, m, i, j, k, ans;
int main() {
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++) scanf("%d", &a[i][j]);
  for (i = 1; i <= n; i++) {
    for (j = i; j <= n; j++) {
      for (k = 1; k <= m; k++) p[a[i][k]] = p[a[j][k]] = 0;
      for (k = 1; k <= m; k++) {
        if (a[i][k] == a[j][k] && i != j) p[a[i][k]] = k;
        dp[i][j][k] = max((int)dp[i][j][k], max(p[a[i][k]], p[a[j][k]]));
        p[a[i][k]] = k;
        p[a[j][k]] = k;
      }
    }
  }
  for (i = 0; i < n; i++)
    for (j = 1; j <= n - i; j++)
      for (k = 1; k <= m; k++) {
        dp[j][i + j][k] = max(dp[j][i + j][k], dp[j][i + j][k - 1]);
        dp[j][i + j][k] =
            max(max(dp[j][i + j][k], dp[j + 1][i + j][k]), dp[j][i + j - 1][k]);
        ans = max(ans, (i + 1) * (k - dp[j][i + j][k]));
      }
  cout << ans;
  return 0;
}
