#include <bits/stdc++.h>
int a[405][405], top[405][405];
short pos[405 * 405][405];
inline void chkmax(int &x, int y) {
  if (x < y) x = y;
}
int main() {
  int n, m, i, j, l, r, rlt;
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++) scanf("%d", a[i] + j);
  rlt = 0;
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++)
      for (l = 1; l <= m - j + 1; l++) {
        r = l + j - 1;
        if (l == r)
          chkmax(top[l][r], pos[a[i][l]][l]);
        else if (a[i][l] == a[i][r])
          top[l][r] = i;
        else {
          chkmax(top[l][r], top[l + 1][r]);
          chkmax(top[l][r], top[l][r - 1]);
          chkmax(top[l][r], pos[a[i][l]][r]);
          chkmax(top[l][r], pos[a[i][r]][l]);
        }
        chkmax(rlt, (i - top[l][r]) * j);
      }
    for (j = 1; j <= m; j++) pos[a[i][j]][j] = i;
  }
  printf("%d\n", rlt);
}
