#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
	int h,w;
	cin>>h>>w;
	vector<vector<int> > dp(h,vector<int>(w,0)),a(h,vector<int>(w,0));
	int ans =0;
	rep(i,h)rep(j,w){
		cin>>a[i][j],dp[i][j]=1-a[i][j];
		if(a[i][j]==0)ans=1;
	}
	rep(i,h-1)rep(j,w-1)
		if(!a[i+1][j+1]){
		dp[i+1][j+1] = min(dp[i][j],min(dp[i+1][j],dp[i][j+1]))+1;
		ans = max(ans,dp[i+1][j+1]*dp[i+1][j+1]);
		}
	cout<<ans<<endl;

	return 0;
}

