# Python3 splitInput = input().split() n = int(splitInput[0]) k = int(splitInput[1]) splitInput = input().split() inputs = [] difNums = [] i = int(0) while i < n: inputs.append(int(splitInput[i])) if difNums.count(inputs[i]) == 0: difNums.append(inputs[i]) i += 1 output = int(0) o = int(0) p = int(0) if difNums >= k: while o < n: while p < n: if difNums.count(inputs[p]) == 0: difNums.append(inputs[p]) output += 1 p += 1 if len(difNums) > k: output -= 1 difNums.clear() p = n o += 1 p = o difNums.clear() else: output = n * (n+1) / 2 print(output)