#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const double eps = 1e-8;
const int maxn = 400 + 10;
short dp[maxn][maxn];
int a[maxn][maxn];
short up[maxn * maxn][maxn];
int main() {
  int n, m;
  while (scanf("%d%d", &n, &m) != EOF) {
    memset(dp, 0, sizeof(dp));
    memset(up, 0, sizeof(up));
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= m; j++) scanf("%d", &a[i][j]);
    int ans = 0;
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) {
        dp[j][j] = max(dp[j][j], up[a[i][j]][j]);
        up[a[i][j]][j] = i;
      }
      for (int L = 1; L <= m; L++)
        for (int R = L + 1; R <= m; R++) {
          dp[L][R] = max(dp[L][R], up[a[i][L]][R]);
          dp[L][R] = max(dp[L][R], up[a[i][R]][L]);
        }
      for (int Len = 2; Len <= m; Len++)
        for (int L = 1; L + Len - 1 <= m; L++) {
          int R = L + Len - 1;
          dp[L][R] = max(dp[L][R], max(dp[L + 1][R], dp[L][R - 1]));
        }
      for (int L = 1; L <= m; L++)
        for (int R = L; R <= m; R++)
          ans = max(ans, (R - L + 1) * (i - dp[L][R]));
    }
    printf("%d\n", ans);
  }
  return 0;
}
