#include <iostream>
#include <set>
#include <pthread.h>
using namespace std;
int n, k;
int *a;
long long int ret = 0;
int tc = 0;
void *perform_work(void *arg)
{
pair<int, int> *se = (pair<int, int>*)arg;
for(int i = se->first; i < se->second; i++)
{
set<int> nums;
int u = 0;
for(int j = 0; i+j < n; j++)
{
if(!nums.count(a[i+j]))
{
nums.insert(a[i+j]);
u++;
}
if(u > k)
break;
ret++;
}
}
tc--;
}
int main()
{
cin >> n >> k;
a = new int[n];
for(int i = 0; i < n; i++)
cin >> a[i];
pthread_t threads[8];
tc = 8;
pthread_create(&threads[0], NULL, perform_work, new pair<int, int>(0, n / 8));
pthread_create(&threads[1], NULL, perform_work, new pair<int, int>(1 * n / 8, 2 * n / 8));
pthread_create(&threads[2], NULL, perform_work, new pair<int, int>(2 * n / 8, 3 * n / 8));
pthread_create(&threads[3], NULL, perform_work, new pair<int, int>(3 * n / 8, 4 * n / 8));
pthread_create(&threads[4], NULL, perform_work, new pair<int, int>(4 * n / 8, 5 * n / 8));
pthread_create(&threads[5], NULL, perform_work, new pair<int, int>(5 * n / 8, 6 * n / 8));
pthread_create(&threads[6], NULL, perform_work, new pair<int, int>(6 * n / 8, 7 * n / 8));
pthread_create(&threads[7], NULL, perform_work, new pair<int, int>(7 * n / 8, n));
while(tc);
cout << ret << endl;
return 0;
}