#include<bits/stdc++.h>
#define ll long long
#define task ""
using namespace std;
const ll N=1e6+11;
ll n,a[1001][1001],m,f[1001],l[1001],r[1001],maxval=0;
void input(){
cin>>m>>n;
for(ll i=1;i<=m;i++){
for(ll j=1;j<=n;j++){
cin>>a[i][j];
}
}
}
void area(ll val01){
fill(f,f+n+1,0);
for(ll i=1;i<=m;i++){
fill(l,l+n+1,0);
fill(r,r+n+1,n+1);
for(ll j=1;j<=n;j++){
if(a[i][j]!=val01){
f[j]=i;
}
}
stack<ll> stl;
for(ll j=1;j<=n;j++){
while(!stl.empty()&&f[stl.top()]<=f[j]){
stl.pop();
}
if(!stl.empty()){
l[j]=stl.top();
}
else{
l[j]=0;
}
stl.push(j);
}
stack<ll> str;
for(ll j=n;j>=1;j--){
while(!str.empty()&&f[str.top()]<=f[j]){
str.pop();
}
if(!str.empty()){
r[j]=str.top();
}
else{
r[j]=n+1;
}
str.push(j);
}
for(ll j=1;j<=n;j++){
maxval=max(maxval,(i-f[j])*(r[j]-l[j]-1));
}
}
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
/*
freopen(".INP","r",stdin);
freopen(".OUT","w",stdout);
*/
input();
area(1);
cout<<maxval;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KI2RlZmluZSBsbCBsb25nIGxvbmcKI2RlZmluZSB0YXNrICIiCnVzaW5nIG5hbWVzcGFjZSBzdGQ7CmNvbnN0IGxsIE49MWU2KzExOwpsbCBuLGFbMTAwMV1bMTAwMV0sbSxmWzEwMDFdLGxbMTAwMV0sclsxMDAxXSxtYXh2YWw9MDsKdm9pZCBpbnB1dCgpewogICAgY2luPj5tPj5uOwogICAgZm9yKGxsIGk9MTtpPD1tO2krKyl7CiAgICAgICAgZm9yKGxsIGo9MTtqPD1uO2orKyl7CiAgICAgICAgICAgIGNpbj4+YVtpXVtqXTsKICAgICAgICB9CiAgICB9Cn0Kdm9pZCBhcmVhKGxsIHZhbDAxKXsKICAgIGZpbGwoZixmK24rMSwwKTsKICAgIGZvcihsbCBpPTE7aTw9bTtpKyspewogICAgICAgIGZpbGwobCxsK24rMSwwKTsKICAgICAgICBmaWxsKHIscituKzEsbisxKTsKICAgICAgICBmb3IobGwgaj0xO2o8PW47aisrKXsKICAgICAgICAgICAgaWYoYVtpXVtqXSE9dmFsMDEpewogICAgICAgICAgICAgICAgZltqXT1pOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIHN0YWNrPGxsPiBzdGw7CiAgICAgICAgZm9yKGxsIGo9MTtqPD1uO2orKyl7CiAgICAgICAgICAgIHdoaWxlKCFzdGwuZW1wdHkoKSYmZltzdGwudG9wKCldPD1mW2pdKXsKICAgICAgICAgICAgICAgIHN0bC5wb3AoKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZighc3RsLmVtcHR5KCkpewogICAgICAgICAgICAgICAgbFtqXT1zdGwudG9wKCk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZWxzZXsKICAgICAgICAgICAgICAgIGxbal09MDsKICAgICAgICAgICAgfQogICAgICAgICAgICBzdGwucHVzaChqKTsKICAgICAgICB9CiAgICAgICAgc3RhY2s8bGw+IHN0cjsKICAgICAgICBmb3IobGwgaj1uO2o+PTE7ai0tKXsKICAgICAgICAgICAgd2hpbGUoIXN0ci5lbXB0eSgpJiZmW3N0ci50b3AoKV08PWZbal0pewogICAgICAgICAgICAgICAgc3RyLnBvcCgpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmKCFzdHIuZW1wdHkoKSl7CiAgICAgICAgICAgICAgICByW2pdPXN0ci50b3AoKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBlbHNlewogICAgICAgICAgICAgICAgcltqXT1uKzE7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgc3RyLnB1c2goaik7CiAgICAgICAgfQogICAgICAgIGZvcihsbCBqPTE7ajw9bjtqKyspewogICAgICAgICAgICBtYXh2YWw9bWF4KG1heHZhbCwoaS1mW2pdKSoocltqXS1sW2pdLTEpKTsKICAgICAgICB9CiAgICB9Cn0KaW50IG1haW4oKXsKICAgIGlvc19iYXNlOjpzeW5jX3dpdGhfc3RkaW8oZmFsc2UpOwogICAgY2luLnRpZSgwKTtjb3V0LnRpZSgwKTsKICAgIC8qCiAgICBmcmVvcGVuKCIuSU5QIiwiciIsc3RkaW4pOwogICAgZnJlb3BlbigiLk9VVCIsInciLHN0ZG91dCk7CiAgICAqLwogICAgaW5wdXQoKTsKICAgIGFyZWEoMSk7CiAgICBjb3V0PDxtYXh2YWw7Cn0K