#include <bits/stdc++.h>
using namespace std;
inline long long sqr(long long x) { return x * x; }
int n, m, vis[405][160005], a[405][405], dp[405][405];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = (1), _b = (n); i <= _b; ++i)
    for (int j = (1), _b = (m); j <= _b; ++j) scanf("%d", &a[i][j]);
  int ans = 0;
  for (int i = (1), _b = (n); i <= _b; ++i) {
    for (int len = (1), _b = (m); len <= _b; ++len)
      for (int j = (1), _b = (m - len + 1); j <= _b; ++j) {
        int k = j + len - 1;
        if (j == k)
          dp[j][k] = max(dp[j][k], vis[j][a[i][j]]);
        else {
          dp[j][k] = max(dp[j][k], max(dp[j + 1][k], dp[j][k - 1]));
          dp[j][k] = max(dp[j][k], max(vis[k][a[i][j]], vis[j][a[i][k]]));
          if (a[i][j] == a[i][k]) dp[j][k] = i;
        }
        ans = max(ans, (i - dp[j][k]) * len);
      }
    for (int j = (1), _b = (m); j <= _b; ++j) vis[j][a[i][j]] = i;
  }
  printf("%d", ans);
  return 0;
}
