Problem7315--CodeChef MATRIX2 - Matrix

7315: CodeChef MATRIX2 - Matrix

[Creator : ]
Time Limit : 1.000 sec  Memory Limit : 256 MiB

Description

You are given a matrix A that consists of N rows and M columns. Every number in the matrix is either zero or one. Calculate the number of such triples (ijh) where for all the pairs (xy), where both x and y belong to [1h] if y >= xA[i+x-1][j+y-1] equals to one. Of course, the square (iji+h-1j+h-1) should be inside of this matrix. In other words, we're asking you to calculate the amount of square submatrices of a given matrix which have ones on and above their main diagonal.

Input

The first line of the input consists of two integers - N and M.
The following N lines describe the matrix. Each line consists of M characters that are either zero or one.

Output

Output should consist of a single integer - the answer to the problem.

Constraints

$1 \leq N,M \leq 2000$.

Sample 1 Input

2 3
011
111

Sample 1 Output

6

HINT

难度系数:2209
题目来源:CodeChef MATRIX2

Source/Category