#include <bits/stdc++.h>
using namespace std;
int dp[2][404][404], freq[160005], n, m, a[404][404], v[16005], pre[404];
int main() {
  int Left, Right, lin = 1, sol = 1, cnt, x, y;
  cin.sync_with_stdio(false);
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) cin >> a[i][j];
    Left = 1;
    for (int j = 1; j <= m; ++j) {
      x = a[i][j];
      ++freq[x];
      while (freq[x] > 1) {
        dp[lin][i][Left] = j - 1;
        sol = max(sol, j - 1 - Left + 1);
        --freq[a[i][Left]];
        ++Left;
      }
    }
    while (Left <= m) {
      dp[lin][i][Left] = m;
      sol = max(sol, m - Left + 1);
      --freq[a[i][Left]];
      ++Left;
    }
  }
  lin = 0;
  for (int nr = 2; nr <= n; ++nr, lin ^= 1) {
    for (int line1 = 1; line1 + nr - 1 <= n; ++line1) {
      int line2 = line1 + nr - 1;
      Left = 1;
      for (int j = 1; j <= m; ++j) {
        x = a[line1][j];
        y = a[line2][j];
        ++freq[x], ++freq[y];
        while (freq[x] > 1 || freq[y] > 1) {
          pre[Left] = j - 1;
          --freq[a[line1][Left]];
          --freq[a[line2][Left]];
          ++Left;
        }
      }
      while (Left <= m) {
        dp[lin][line1][Left] = m;
        pre[Left] = m;
        x = a[line1][Left];
        y = a[line2][Left];
        --freq[x], --freq[y];
        ++Left;
      }
      for (Left = 1; Left <= m; ++Left) {
        Right = min(dp[lin ^ 1][line1][Left], dp[lin ^ 1][line1 + 1][Left]);
        Right = min(Right, pre[Left]);
        dp[lin][line1][Left] = Right;
        sol = max(sol, nr * (Right - Left + 1));
      }
    }
  }
  cout << sol << "\n";
  return 0;
}
