Problem3043--C. 相对领先

3043: C. 相对领先

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

Description

恭喜入选宇航员预备队的小家伙们,但是接下来他们将面对是一系列充满挑战性的训练。为了快速提高大家的各方面水平,宇航局特意请来了高斯作为教练,进行为期 lns="http://www.w3.org/1998/Math/MathML">w 周的训练。

每周训练结束后,高斯会对编号为 lns="http://www.w3.org/1998/Math/MathML">1 \ldots n 的学员们进行排名,并对大家的成绩做出科学的分析。

其中一项指标称为相对分析,即如果编号为 lns="http://www.w3.org/1998/Math/MathML">i 的学员每周的排名都领先于编号为 lns="http://www.w3.org/1998/Math/MathML">j 的学员,我们就称学员 lns="http://www.w3.org/1998/Math/MathML">i 相对领先于学员 lns="http://www.w3.org/1998/Math/MathML">j

现在请你编程帮助高斯计算一下, lns="http://www.w3.org/1998/Math/MathML">w 周的训练结束后,有多少对这样的相对领先关系。

Input

输入的第一行包含两个正整数 lns="http://www.w3.org/1998/Math/MathML">w 和 lns="http://www.w3.org/1998/Math/MathML">n

接下来的 lns="http://www.w3.org/1998/Math/MathML">w 行每行包含 lns="http://www.w3.org/1998/Math/MathML">n个整数,表示学员的排名(学员的编号为 lns="http://www.w3.org/1998/Math/MathML">1 \ldots n 的整数)。

排名越靠前,说明表现得越好。

Output

输出一个整数,表示相对领先得对数。

Sample Input Copy

3 5
4 1 2 3 5
4 1 3 2 5
5 4 2 1 3 

Sample Output Copy

4

HINT

样例2输入

3 3
1 2 3
1 3 2
1 3 2

样例2输出

2


说明:

【样例1解释】

lns="http://www.w3.org/1998/Math/MathML">3 周训练中,保持相对领先关系得数对有 lns="http://www.w3.org/1998/Math/MathML">[4,1],[4,2],[4,3],[1,3] , 共 lns="http://www.w3.org/1998/Math/MathML">4 对。

【数据范围】

lns="http://www.w3.org/1998/Math/MathML">1 \leq w \leq 10

lns="http://www.w3.org/1998/Math/MathML">1 \leq n \leq 20

Source/Category