#include <bits/stdc++.h>
using namespace std;
const int N = 405;
int a[N][N];
int c[N][160005];
int n, m;
int f[N][N];
int ans;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = (1); i <= (int)n; i++)
    for (int j = (1); j <= (int)m; j++) scanf("%d", &a[i][j]);
  for (int i = (1); i <= (int)n; i++) {
    for (int len = (1); len <= (int)m; len++)
      for (int l = (1); l <= (int)m - len + 1; l++) {
        int r = l + len - 1;
        if (l == r)
          f[l][r] = max(f[l][r], c[l][a[i][l]]);
        else {
          f[l][r] = max(f[l][r], max(f[l + 1][r], f[l][r - 1]));
          f[l][r] = max(f[l][r], max(c[l][a[i][r]], c[r][a[i][l]]));
          if (a[i][l] == a[i][r]) f[l][r] = i;
        }
        ans = max(ans, (i - f[l][r]) * (r - l + 1));
      }
    for (int j = (1); j <= (int)m; j++) c[j][a[i][j]] = i;
  }
  printf("%d\n", ans);
  return 0;
}
