#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9, mod = 1e9 + 7;
const int N = 401;
int n, m, a[N][N], dp[N][N], ans;
short f[N * N][N];
int main() {
  scanf("%d %d", &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 <= n; i++) {
    for (int le = 1; le <= m; le++)
      for (int l = 1; l <= m - le + 1; l++) {
        int r = l + le - 1;
        if (le == 1) {
          dp[l][r] = max(dp[l][r], f[a[i][l]][l] + 1);
          f[a[i][l]][l] = i;
        } else
          dp[l][r] = max(max(dp[l][r], max(dp[l][r - 1], dp[l + 1][r])),
                         max(f[a[i][l]][r] + 1, f[a[i][r]][l] + 1));
        ans = max(ans, (i - dp[l][r] + 1) * (r - l + 1));
      }
  }
  cout << ans << '\n';
  return 0;
}
