#include <bits/stdc++.h>
using namespace std;
const int N = 404;
int n, m;
int a[N][N], f[N][N], p[N][160004];
int main() {
  while (~scanf("%d%d", &n, &m)) {
    for (int i = (1); i < (n + 1); i++)
      for (int j = (1); j < (m + 1); j++) scanf("%d", &a[i][j]);
    memset(f, 0, sizeof(f));
    memset(p, 0, sizeof(p));
    int ans = 1;
    for (int i = (1); i < (n + 1); i++) {
      for (int len = (1); len < (m + 1); len++) {
        for (int l = 1, r = len; r <= m; ++l, ++r) {
          if (l == r) {
            f[l][r] = max(f[l][r], p[l][a[i][l]]);
          } else {
            f[l][r] = max(f[l][r], max(f[l][r - 1], f[l + 1][r]));
            f[l][r] = max(f[l][r], max(p[l][a[i][r]], p[r][a[i][l]]));
            if (a[i][l] == a[i][r]) f[l][r] = i;
          }
          ans = max(ans, (i - f[l][r]) * (r - l + 1));
        }
      }
      for (int j = (1); j < (m + 1); j++) p[j][a[i][j]] = i;
    }
    printf("%d\n", ans);
  }
  return 0;
}
