#include <bits/stdc++.h>
using namespace std;
using namespace std;
int n, m, a[405][405];
int f[405][405];
int L[160000][405];
void work() {
  int i, j, k, ans = 0;
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; ++i)
    for (j = 1; j <= m; ++j) scanf("%d", &a[i][j]), --a[i][j];
  for (i = 1; i <= m; ++i)
    for (j = 1; j <= m; ++j) f[i][j] = 1;
  for (i = 1; i <= n; ++i) {
    for (j = 1; j <= m; ++j) {
      for (k = 1; k <= m; ++k) {
        int l = j, r = k;
        if (l > r) swap(l, r);
        f[l][r] = max(f[l][r], L[a[i][j]][k]);
      }
      L[a[i][j]][j] = i + 1;
    }
    for (j = 2; j <= m; ++j) {
      for (k = 1; k + j - 1 <= m; ++k) {
        f[k][k + j - 1] = max(f[k][k + j - 1], f[k + 1][k + j - 1]);
        f[k][k + j - 1] = max(f[k][k + j - 1], f[k][k + j - 2]);
      }
    }
    for (j = 1; j <= m; ++j)
      for (k = j; k <= m; ++k) ans = max(ans, (k - j + 1) * (i - f[j][k] + 1));
  }
  cout << ans << endl;
}
int main() {
  work();
  return 0;
}
