#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;
}
