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