#include <bits/stdc++.h>
using namespace std;
const int N = 402;
int n, m;
int a[N][N], f[N][N], c[N * N][N];
int ans = 0;
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]);
  for (int k(1); k <= (n); ++k) {
    for (int i(1); i <= (m); ++i)
      f[i][i] = max(f[i][i], c[a[k][i]][i]), c[a[k][i]][i] = k;
    for (int i(1); i <= (m); ++i)
      for (int j(i + 1); j <= (m); ++j)
        f[i][j] = max(f[i][j], max(c[a[k][i]][j], c[a[k][j]][i]));
    for (int i(m); i >= (1); --i)
      for (int j(i + 1); j <= (m); ++j)
        f[i][j] = max(f[i][j], max(f[i + 1][j], f[i][j - 1]));
    for (int i(1); i <= (m); ++i)
      for (int j(i); j <= (m); ++j) ans = max(ans, (j - i + 1) * (k - f[i][j]));
  }
  printf("%d\n", ans);
  return 0;
}
