#include <iostream>
#include <vector>
using namespace std;
typedef vector <unsigned long> lVect;
typedef unsigned long ul;
ul countNonZero(vector <lVect>* items) {
ul n = 0;
for (ul i = 0; i < (*items).size(); i++) {
if ((*items)[i][1] != 0) {
n += 1;
}
}
return n;
}
ul countDynamic(vector <ul>* seq, int size, int k) {
ul validSublists = 0;
vector <lVect> items(*max_element(seq->begin(), seq->end()) + 1);
for (ul i = 0; i < items.size(); i++) {
vector <ul> c = {i, 0};
items[i] = c;
}
for (ul j = 0; j < size; j++) {
ul index = (*seq)[j];
// cout << "seq[j]: " << index << endl;
items[index][1] += 1;
}
if (countNonZero(&items) <= k) {
validSublists += 1;
}
for (ul 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 <ul> list(arrayLength);
for (int i = 0; i < arrayLength; i++) {
int next;
cin >> next;
list[i] = next;
}
ul 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;
}