#include <bits/stdc++.h>
#define MOD 1000000007
typedef long long ll;
using namespace std;
char a[2501][2501];
int main(){
//ios_base::sync_with_stdio(NULL);
// cin.tie(NULL);
// cout.tie(NULL);
int n,m;
cin >> n >>m;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
cin >> a[i][j];
}
}
int l,r,width=m,length=n;
for(int i=1;i<=n;i++){
l=-1,r=-1;
for(int j=1;j<=m;j++){
if(a[i][j]=='0'){
if(l!=-1){
width=min(width,r-l+1);
}
l=-1;
}
else{
if(l==-1){
l=j;
}
r=j;
}
}
if(l!=-1) width=min(width,r-l+1);
}
for(int i=1;i<=m;i++){
l=-1,r=-1;
for(int j=1;j<=n;j++){
if(a[j][i]=='0'){
if(l!=-1){
length=min(length,r-l+1);
}
l=-1;
}
else{
if(l==-1){
l=j;
}
r=j;
}
}
if(l!=-1) length=min(length,r-l+1);
}
cout << width*length;
}