#include <bits/stdc++.h>
using namespace std;
int n, m;
int a[401][401];
int f[160001][401];
int dp[500][500];
int main() {
  scanf("%d%d", &n, &m);
  memset(f, 0, sizeof f);
  memset(dp, 0, sizeof dp);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) scanf("%d", &a[i][j]);
  int ans = 0;
  for (int k = 1; k <= n; k++) {
    for (int i = m; i >= 1; i--) {
      dp[i][i] = max(dp[i][i], f[a[k][i]][i] + 1);
      ans = max(ans, k - dp[i][i] + 1);
      f[a[k][i]][i] = k;
      for (int j = i + 1; j <= m; j++) {
        dp[i][j] =
            max(dp[i][j - 1],
                max(dp[i + 1][j],
                    max(f[a[k][i]][j] + 1, max(f[a[k][j]][i] + 1, dp[i][j]))));
        ans = max(ans, (j - i + 1) * (k - dp[i][j] + 1));
      }
    }
  }
  printf("%d\n", ans);
}
