#include <bits/stdc++.h>
using namespace std;
int n, m;
int a[401][401];
bool bo[160001];
short lmost[401][401][401];
short int f[401][401][401];
void init() {
  int i, j, k;
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++) {
      scanf("%d", &k);
      a[i][j] = k;
    }
}
void solve() {
  int i, j, k, l, r;
  memset(lmost, 0, sizeof(lmost));
  memset(bo, 0, sizeof(bo));
  for (i = 1; i <= n; i++) {
    for (j = i + 1; j <= n; j++) {
      l = m;
      for (r = m; r >= 1; r--) {
        while (l >= 1 && a[i][l] != a[j][l] && !bo[a[i][l]] && !bo[a[j][l]]) {
          bo[a[i][l]] = 1;
          bo[a[j][l]] = 1;
          l--;
        }
        lmost[i][j][r] = l + 1;
        bo[a[i][r]] = 0;
        bo[a[j][r]] = 0;
        l = min(l, r - 1);
      }
    }
    l = m;
    for (r = m; r >= 1; r--) {
      while (l >= 1 && !bo[a[i][l]]) {
        bo[a[i][l]] = 1;
        l--;
      }
      lmost[i][i][r] = l + 1;
      bo[a[i][r]] = 0;
      l = min(l, r - 1);
    }
  }
  memset(f, 0, sizeof(f));
  int ans = 0;
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      f[i][i][j] = lmost[i][i][j];
      ans = max(ans, j - f[i][i][j] + 1);
    }
  }
  int len;
  for (len = 2; len <= n; len++) {
    for (i = 1; i <= n - len + 1; i++) {
      j = i + len - 1;
      for (r = 1; r <= m; r++) {
        f[i][j][r] = max(max(f[i + 1][j][r], f[i][j - 1][r]), lmost[i][j][r]);
        ans = max((r - f[i][j][r] + 1) * len, ans);
      }
    }
  }
  printf("%d\n", ans);
}
int main() {
  init();
  solve();
  return 0;
}
