#include <bits/stdc++.h>
using namespace std;
int i, j, k, l, n, m, s, an, sum, tot = 1, len, K, r, MA, MI, M, s1, s2, L, R;
const int N = 410;
bool bst;
int a[N][N];
short int f[N][N], g[N][N];
bool ok[N];
short int use[N][N * N];
bool bed;
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 i = 1; i <= n; i++) {
    for (int l = m; l >= 1; l--)
      for (int r = l; r <= m; r++) {
        f[l][r] = max(f[l][r], max(use[r][a[i][l]], use[l][a[i][r]]));
        f[l][r] = max(f[l][r], max(f[l + 1][r], f[l][r - 1]));
        if ((l != r) && (a[i][l] == a[i][r])) f[l][r] = i;
        g[l][r] = max(g[l][r], f[l][r]);
        an = max(an, (r - l + 1) * (i - g[l][r]));
      }
    for (int j = 1; j <= m; j++) use[j][a[i][j]] = i;
  }
  printf("%d\n", an);
  return 0;
}
