#include <bits/stdc++.h>
using namespace std;
short f[401][401];
short limit[401 * 401][401];
int a[401][401];
int n, m;
int ans;
void init() {
  scanf("%d%d", &n, &m);
  memset(f, 0, sizeof(f));
  memset(limit, 0, sizeof(limit));
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) scanf("%d", &a[i][j]);
}
void dp() {
  ans = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      f[j][j] =
          ((f[j][j]) > (limit[a[i][j]][j]) ? (f[j][j]) : (limit[a[i][j]][j]));
      limit[a[i][j]][j] = i;
    }
    for (int left = 1; left < m; left++) {
      for (int right = left + 1; right <= m; right++) {
        f[left][right] = ((f[left][right]) > (limit[a[i][left]][right])
                              ? (f[left][right])
                              : (limit[a[i][left]][right]));
        f[left][right] = ((f[left][right]) > (limit[a[i][right]][left])
                              ? (f[left][right])
                              : (limit[a[i][right]][left]));
      }
    }
    for (int j = 2; j <= m; j++) {
      for (int left = 1; left <= m - j + 1; left++) {
        int right = left + j - 1;
        f[left][right] =
            ((f[left][right]) > (f[left][right - 1]) ? (f[left][right])
                                                     : (f[left][right - 1]));
        f[left][right] =
            ((f[left][right]) > (f[left + 1][right]) ? (f[left][right])
                                                     : (f[left + 1][right]));
      }
    }
    for (int left = 1; left <= m; left++)
      for (int right = left; right <= m; right++)
        ans = ((ans) > ((right - left + 1) * (i - f[left][right]))
                   ? (ans)
                   : ((right - left + 1) * (i - f[left][right])));
  }
}
int main() {
  init();
  dp();
  printf("%d\n", ans);
  return 0;
}
