#include <bits/stdc++.h>
using namespace std;
int a[401][401], f[401][401], p[401][160001], n, m;
void read(int &x) {
  char ch = getchar();
  int mark = 1;
  for (; ch != '-' && (ch < '0' || ch > '9'); ch = getchar())
    ;
  if (ch == '-') mark = -1, ch = getchar();
  for (x = 0; ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - 48;
  x *= mark;
}
int main() {
  read(n);
  read(m);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) read(a[i][j]);
  int ans = 0;
  for (int j = 1; j <= m; j++) {
    for (int up = n; up; up--)
      for (int down = up; down <= n; down++) {
        f[up][down] =
            max(f[up][down], max(max(f[up + 1][down], f[up][down - 1]),
                                 max(p[up][a[down][j]], p[down][a[up][j]])));
        if (up < down && a[up][j] == a[down][j]) f[up][down] = j;
        ans = max(ans, (down - up + 1) * (j - f[up][down]));
      }
    for (int i = 1; i <= n; i++) p[i][a[i][j]] = j;
  }
  printf("%d\n", ans);
  return 0;
}
