#include <bits/stdc++.h>
using namespace std;
short dp[405][405][405], i, j, k, col[405][160005];
int res, d[405][405], n, m;
short min(short a, short b) { return a > b ? b : a; }
int main() {
  scanf("%d %d", &n, &m);
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++) scanf("%d", &d[i][j]);
  memset(dp, 63, sizeof dp);
  for (i = 1; i <= n; i++) {
    for (j = m; j; j--) {
      for (k = j; k <= m; k++) {
        dp[i][j][k] = min(dp[i][j][k], (short)1 + dp[i - 1][j][k]);
        if (j < k) {
          dp[i][j][k] = min(dp[i][j][k], dp[i][j + 1][k]);
          dp[i][j][k] = min(dp[i][j][k], dp[i][j][k - 1]);
        }
        dp[i][j][k] = min(dp[i][j][k], i - col[j][d[i][k]]);
        dp[i][j][k] = min(dp[i][j][k], i - col[k][d[i][j]]);
        if (d[i][j] == d[i][k] and j != k) dp[i][j][k] = 0;
        res = max(res, (int)dp[i][j][k] * (k - j + 1));
      }
    }
    for (j = 1; j <= m; j++) col[j][d[i][j]] = i;
  }
  cout << res << endl;
  return 0;
}
