e-olymp
favorite We need a little bit of your help to keep things running, click on this banner to learn more
Competitions

Two dimensional arrays

Saddle points

The matrix K is given. It contains n rows and m columns. The saddle point of the matrix is an element that is minimum in its row and the maximum in its column.

Find the number of saddle points in a given matrix.

Input

The first line contains two integers n and m (1n, m750). Then given n rows with m numbers in each. The j-th number of the i-th line equals to kij. All kij do not exceed 1000 by absolute value.

Output

Print the number of saddle points.

Time limit 2 second
Memory limit 128 MiB
Input example #1
2 2
0 0
0 0
Output example #1
4
Input example #2
2 2
1 2
3 4
Output example #2
1