#include <bits/stdc++.h>
using namespace std;
const int maxn = 401;
int n, m, res;
int a[maxn][maxn];
vector<int> b;
map<int, int> mp;
short maxR[maxn][maxn], pos_R[maxn][maxn * maxn];
void read(int& x) {
  x = 0;
  int c = 0;
  do {
    c = getchar();
  } while (c < '0' || c > '9');
  do {
    x = x * 10 + c - '0';
    c = getchar();
  } while (!(c < '0' || c > '9'));
}
int main() {
  read(n);
  read(m);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      read(a[i][j]);
      b.push_back(a[i][j]);
    }
  }
  for (int i = 0; i < maxn; i++)
    for (int j = 0; j < maxn; j++) maxR[i][j] = m + 1;
  for (int i = 0; i < maxn; i++)
    for (int j = 0; j < maxn * maxn; j++) pos_R[i][j] = m + 1;
  for (int left = m; left >= 1; left--) {
    for (int i = 1; i <= n; i++) {
      maxR[i][i] = min(maxR[i][i], pos_R[i][a[i][left]]);
      res = max(res, maxR[i][i] - left);
    }
    for (int i = 1; i <= n; i++) pos_R[i][a[i][left]] = left;
    for (int up = n; up >= 1; up--) {
      for (int down = up + 1; down <= n; down++) {
        maxR[up][down] =
            min(maxR[up][down], min(maxR[up + 1][down], maxR[up][down - 1]));
        maxR[up][down] = min(maxR[up][down], min(pos_R[up][a[down][left]],
                                                 pos_R[down][a[up][left]]));
        res = max(res, (down - up + 1) * (maxR[up][down] - left));
      }
    }
  }
  cout << res << "\n";
}
