#include <bits/stdc++.h>
using namespace std;
int a[405][405];
int u[405][405][405];
int v[160005];
int main() {
  int n, m, ans = 0;
  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 j = m; j; j--) {
    for (int k = j; k <= m; k++) {
      int t = 0;
      for (int i = 1; i <= n; i++) {
        int c = max(u[i][j][k - 1], u[i][j + 1][k]);
        c = max(c, u[i - 1][j][k]);
        if (a[i][j] == a[i][k] && j != k)
          while (t < i) {
            v[a[++t][j]]--;
            v[a[t][k]]--;
          }
        else
          while (v[a[i][j]] || v[a[i][k]]) {
            v[a[++t][j]]--;
            v[a[t][k]]--;
          }
        v[a[i][j]]++;
        v[a[i][k]]++;
        u[i][j][k] = max(c, t);
        ans = max(ans, (k - j + 1) * (i - u[i][j][k]));
      }
      while (t < n) {
        v[a[++t][j]]--;
        v[a[t][k]]--;
      }
    }
  }
  printf("%d\n", ans);
}
