#include <bits/stdc++.h>
using namespace std;
int a[402][402], vis[160005], b[160005];
int main() {
  int i, j, k, l, r, c, m, n, sm = 0, cnt = 0, p;
  cin >> n >> m;
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      cin >> a[i][j];
    }
  }
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      cnt++;
      int nm = m + 1;
      for (r = i; r <= n; r++) {
        if ((nm - j) * (n - i + 1) <= sm) break;
        for (c = j; c < nm && c <= m; c++) {
          p = a[r][c];
          if (vis[p] != cnt) {
            vis[p] = cnt;
            b[p] = c;
          } else {
            if (b[p] <= c) {
              if (nm > c) nm = c;
              break;
            } else {
              if (nm > b[p]) nm = b[p];
              b[p] = c;
            }
          }
        }
        if (c == j) break;
        sm = max(sm, (r - i + 1) * (c - j));
      }
    }
  }
  cout << sm << endl;
  return 0;
}
