J. Local Minimum
time limit per test
1 second
memory limit per test
512 megabytes
input
standard input
output
standard output

Given a matrix of size $$$n\times m$$$. Determine the number of entries who equals the minimum value among all other entries of the same row or column. Formally, determine the value of $$$$$$\sum_{i=1}^{n}\sum_{j=1}^{m}\left[\min\{M_{u, v} \, | \, u = i \; \mathrm{or} \; v = j \} = M_{i, j}\right]$$$$$$

Note: $$$[A] = 1$$$ if statement $$$A$$$ is true, or $$$[A] = 0$$$.

Input

The first line contains two integers $$$n,m \, (1 \le n,m \le 1000)$$$, denoting the size of given matrix.

Following $$$n$$$ lines each contains $$$m$$$ integers $$$M_{i,j} \, (1\le M_{i,j} \le 10^6)$$$, denoting the given matrix.

Output

Output one line containing one integer, denoting the answer.

Example
Input
3 3
1 5 9
4 3 7
2 6 2
Output
3
Note

There are 3 entries $$$M_{1,1} = 1, M_{2,2} = 3, M_{3,3} = 2$$$ satisfying the constraint.