728. Count Negative Numbers in a Sorted Matrix

0

Easy

Given a matrix grid with dimensions m x n, where the elements are sorted in non-increasing order both row-wise and column-wise, determine the number of negative numbers in the grid.

Input Format

The input consists of two integers, m and n, on the first line, separated by a space. The following m lines contain n integers each, representing the elements of the matrix grid.

Output Format

Print a single integer, which is the count of negative numbers in the matrix.

Example

Input

4 4
4 3 2 -1
3 2 1 -1
1 1 -1 -2
-1 -1 -2 -3

Output

8

Constraints

m and n are the dimensions of the matrix grid, where m is the number of rows and n is the number of columns. The values of m and n are equal to the length of the grid array. The values of m and n are between 1 and 100, inclusive. The values of the elements in the grid array are between -100 and 100, inclusive.

Loading...

View Submissions

Console