#include <bits/stdc++.h>
using namespace std;
const int maxn = 405;
int n, m, ans;
int a[maxn][maxn], f[maxn][maxn];
short las[maxn * maxn][maxn];
inline bool rel(int &x, const int &y) { return x < y ? (x = y, 1) : 0; }
inline int max(const int &x, const int &y) { return x < y ? y : x; }
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 j = 1; j <= m; j++)
      rel(f[j][j], las[a[i][j]][j]), las[a[i][j]][j] = i;
    for (int l = 1, r; l < m; l++)
      for (r = l + 1; r <= m; r++)
        rel(f[l][r], max(las[a[i][l]][r], las[a[i][r]][l]));
    for (int l = m - 1, r; l > 0; l--)
      for (r = l + 1; r <= m; r++) rel(f[l][r], max(f[l + 1][r], f[l][r - 1]));
    for (int l = 1, r; l <= m; l++)
      for (r = l; r <= m; r++) rel(ans, (r - l + 1) * (i - f[l][r]));
  }
  printf("%d\n", ans);
  return 0;
}
