let a = readLine()!.characters.split{$0 == " "}.map{ Int(String($0))! }
let n = a[0]
let k = a[1]

let arr = readLine()!.characters.split{$0 == " "}.map{ Int(String($0))! }
var set = Set<String>()
for i in 0...arr.count-k {
  var aa = arr
  aa[i..<i+k].sortInPlace()
  let str = String(aa)
  set.insert(str)
}

print(set.count)