Given a matrix of size n×mn×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
∑i=1n∑j=1m[min{Mu,v|u=iorv=j}=Mi,j]∑i=1n∑j=1m[min{Mu,v|u=iorv=j}=Mi,j]
Note: [A]=1 if statement A is true, or [A]=0.
Input
The first line contains two integers n,m(1≤n,m≤1000), denoting the size of given matrix.
Following nn lines each contains mm integers Mi,j(1≤Mi,j≤106), 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 M1,1=