#include <iostream>
#include <vector>
using namespace std;
typedef vector <long> lVect;
long countNonZero(vector <lVect>* items) {
long n = 0;
for (long i = 0; i < (*items).size(); i++) {
if ((*items)[i][1] != 0) {
n += 1;
}
}
return n;
}
long countDynamic(vector <long>* seq, int size, int k) {
long validSublists = 0;
vector <lVect> items(*max_element(seq->begin(), seq->end()) + 1);
for (long i = 0; i < items.size(); i++) {
vector <long> c = {i, 0};
items[i] = c;
}
for (long j = 0; j < size; j++) {
long index = (*seq)[j];
// cout << "seq[j]: " << index << endl;
items[index][1] += 1;
}
if (countNonZero(&items) <= k) {
validSublists += 1;
}
for (long q = size; q < (*seq).size(); q++) {
items[(*seq)[q]][1] += 1;
items[(*seq)[q - size]][1] -= 1;
if (countNonZero(&items) <= k) {
validSublists += 1;
}
}
return validSublists;
}
int main(int argc, const char * argv[]) {
int arrayLength;
int k;
cin >> arrayLength;
cin >> k;
vector <long> list(arrayLength);
for (int i = 0; i < arrayLength; i++) {
int next;
cin >> next;
list[i] = next;
}
long sum = 0;
for (int n = 1; n < k + 1; n++) {
sum += list.size() - n + 1;
}
for (int m = k + 1; m < list.size() + 1; m++) {
sum += countDynamic(&list, m, k);
}
cout << sum;
return 0;
}