hoge = []
hoge = gets.split(' ').map(&:to_i)
n = hoge[0]
k = hoge[1]
ary = gets.split(' ').map(&:to_i)
big = []
k.times do
    big << ary
end
big.flatten!

result = 0
big.each_with_index {|item, idx|
  nokori = big
  nokori.slice!(0..idx)
  nokori.each {|mono|
    result += 1 if item > mono
   }
}
puts result