#include <iostream>
#include <vector>
#include <unordered_set>
#include <set>
int *table;
bool *elim;
std::set<int> *sets;
int main()
{
int n, k;
std::cin >> n >> k;
table = new int[n];
elim = new bool[n];
sets = new std::set<int>[n];
int ans = 0;
std::ios_base::sync_with_stdio(false);
cin.tie(NULL);
for (int i = 0; i < n; ++i) {
std::cin >> table[i];
}
for (int round = 0; round < n; ++round) {
for (int i = 0; i < n - round; ++i) {
if (elim[i])
continue;
sets[i].insert(table[i + round]);
if (sets[i].size() > k) {
elim[i] = true;
}
}
int tmp = ans;
for (int i = 0; i < n - round; ++i) {
if (!elim[i])
++ans;
}
if (ans == tmp)
break;
}
std::cout << ans << std::endl;
}