#include <bits/stdc++.h>
using namespace std;
const int N = 405;
int n, m, f[N][N], d[N][N], p[N][N * N], a[N][N], ans;
int main() {
  cin >> 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 <= m; i++) {
    for (int l = n; l >= 1; l--)
      for (int r = l; r <= n; r++) {
        f[l][r] = max(max(p[l][a[r][i]], p[r][a[l][i]]),
                      max(f[l + 1][r], f[l][r - 1]));
        if (l != r && a[l][i] == a[r][i]) f[l][r] = i;
        d[l][r] = max(d[l][r], f[l][r]);
        ans = max(ans, (i - d[l][r]) * (r - l + 1));
      }
    for (int j = 1; j <= n; j++) p[j][a[j][i]] = i;
  }
  cout << ans << endl;
  return 0;
}
