#include <bits/stdc++.h>
using namespace std;
int p[1600005], a[405][405], ans, i, j, k, n, m;
short dp[405][405][405];
int main() {
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++) scanf("%d", &a[i][j]);
  for (k = 1; k <= n; k++) {
    for (i = 1; i <= 160000; i++) p[i] = 0;
    for (i = 1; i <= m; i++)
      for (j = 1; j <= n; j++) {
        dp[j][i][k] = p[a[j][i]];
        if (j == k) p[a[j][i]] = i;
      }
  }
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++)
      for (k = 1; k <= i; k++) dp[i][j][k] = max(dp[i][j][k], dp[k][j][i]);
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++)
      for (k = i; k >= 1; k--) {
        dp[i][j][k] = max(dp[i][j - 1][k], dp[i][j][k]);
        if (k != i)
          dp[i][j][k] = max(dp[i][j][k], max(dp[i][j][k + 1], dp[i - 1][j][k]));
        ans = max(ans, (i - k + 1) * (j - dp[i][j][k]));
      }
  cout << ans;
  return 0;
}
