// Problem MATRIX2, setter's solution to the sub tasks 2, 3
#include <cstdio>
#include <algorithm>
using namespace std;
int n,m,i,j,h,x,y,b[2005][2005],a[2005][2005],fail,ret;
int main(){
scanf("%d%d\n",&n,&m); // size of the matrix
for(i=1;i<=n;i++){
for(j=1;j<=m;j++)a[i][j]=getchar()-'0'; // reading the matrix
getchar(); // reading a newline
}
for(i=1;i<=n;i++)for(j=1;j<=m;j++)for(h=1;i+h-1<=n&&j+h-1<=m;h++){ // (i, j) is the top left corner, h is the size of the submatrix
for(x=1;x<=h;x++)for(y=1;y<=h;y++)b[x][y]=a[i+x-1][j+y-1];
fail=0;
for(x=1;x<=h;x++)for(y=1;y<=h;y++)if(y>=x&&b[x][y]==0)fail=1; // check the matrix as it's described in the statement
ret+=1-fail;
}
printf("%d\n",ret); // output the answer
return 0;
}
Ly8gUHJvYmxlbSBNQVRSSVgyLCBzZXR0ZXIncyBzb2x1dGlvbiB0byB0aGUgc3ViIHRhc2tzIDIsIDMKCiNpbmNsdWRlIDxjc3RkaW8+CiNpbmNsdWRlIDxhbGdvcml0aG0+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgbixtLGksaixoLHgseSxiWzIwMDVdWzIwMDVdLGFbMjAwNV1bMjAwNV0sZmFpbCxyZXQ7CgppbnQgbWFpbigpewogICAgc2NhbmYoIiVkJWRcbiIsJm4sJm0pOyAvLyBzaXplIG9mIHRoZSBtYXRyaXgKCWZvcihpPTE7aTw9bjtpKyspewoJCWZvcihqPTE7ajw9bTtqKyspYVtpXVtqXT1nZXRjaGFyKCktJzAnOyAvLyByZWFkaW5nIHRoZSBtYXRyaXgKCQlnZXRjaGFyKCk7IC8vIHJlYWRpbmcgYSBuZXdsaW5lCgl9Cglmb3IoaT0xO2k8PW47aSsrKWZvcihqPTE7ajw9bTtqKyspZm9yKGg9MTtpK2gtMTw9biYmaitoLTE8PW07aCsrKXsgLy8gKGksIGopIGlzIHRoZSB0b3AgbGVmdCBjb3JuZXIsIGggaXMgdGhlIHNpemUgb2YgdGhlIHN1Ym1hdHJpeAoJCWZvcih4PTE7eDw9aDt4KyspZm9yKHk9MTt5PD1oO3krKyliW3hdW3ldPWFbaSt4LTFdW2oreS0xXTsKCQlmYWlsPTA7CgkJZm9yKHg9MTt4PD1oO3grKylmb3IoeT0xO3k8PWg7eSsrKWlmKHk+PXgmJmJbeF1beV09PTApZmFpbD0xOyAvLyBjaGVjayB0aGUgbWF0cml4IGFzIGl0J3MgZGVzY3JpYmVkIGluIHRoZSBzdGF0ZW1lbnQKCQlyZXQrPTEtZmFpbDsKCX0KCXByaW50ZigiJWRcbiIscmV0KTsgLy8gb3V0cHV0IHRoZSBhbnN3ZXIKCXJldHVybiAwOwp9