#include <bits/stdc++.h>
using namespace std;
const int N = 402;
short gan[N][N * N];
int a[N][N], n, m, d[N][N], f[N][N], res = 0;
int nen[1000001];
int cnt = 0;
int has[1000001];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j) {
      scanf("%d", &a[i][j]);
      if (!has[a[i][j]]) {
        has[a[i][j]] = ++cnt;
      }
      a[i][j] = has[a[i][j]];
    }
  for (int i = 1; i <= m; ++i) {
    for (int le = n; le >= 1; --le) {
      f[le][le] = max(f[le][le], (int)gan[le][a[le][i]]);
      d[le][le] = max(d[le][le], f[le][le]);
      res = max(res, i - d[le][le]);
      for (int ri = le + 1; ri <= n; ++ri) {
        f[le][ri] = max((int)max(gan[le][a[ri][i]], gan[ri][a[le][i]]),
                        max(f[le][ri - 1], f[le + 1][ri]));
        if (le != ri and a[le][i] == a[ri][i]) f[le][ri] = i;
        d[le][ri] = max(d[le][ri], f[le][ri]);
        res = max(res, (i - d[le][ri]) * (ri - le + 1));
      }
    }
    for (int j = 1; j <= n; ++j) gan[j][a[j][i]] = i;
  }
  printf("%d", res);
}
