#include <bits/stdc++.h>
using namespace std;
map<int, int> dic[160010];
int a[410][410], dp[410][410];
int main() {
  int n, m;
  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 i = 1; i <= m; i++)
    for (int j = 1; j <= m; j++) dp[i][j] = 1;
  int ans = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      int x = a[i][j];
      for (auto it = dic[x].begin(); it != dic[x].end(); it++) {
        int l = it->first, r = j;
        if (l > r) swap(l, r);
        dp[l][r] = max(dp[l][r], it->second);
      }
      dic[x][j] = i + 1;
    }
    for (int len = 1; len <= m; len++) {
      for (int l = 1; l + len - 1 <= m; l++) {
        int r = l + len - 1;
        dp[l][r] = max(dp[l][r], max(dp[l][r - 1], dp[l + 1][r]));
      }
    }
    for (int l = 1; l <= m; l++) {
      for (int r = l; r <= m; r++) {
        ans = max(ans, (i - dp[l][r] + 1) * (r - l + 1));
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}
