#include <bits/stdc++.h>
using namespace std;
int n;
unordered_set<int> a;
int arr[200005];
void funz(int x) {
  unordered_set<int> lolz;
  int asz = a.size();
  int sz = 0;
  for (int i = x; i <= n && asz - sz > 1; i++) {
    if (a.find(arr[i]) != a.end() && lolz.find(arr[i]) == lolz.end()) {
      lolz.insert(arr[i]);
      sz++;
    }
  }
  a.clear();
  a = lolz;
}
int main() {
  int k;
  int ans = 0;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) cin >> arr[i];
  for (int i = 1; i <= n; i++) {
    int x = arr[i];
    int asz = a.size();
    if (asz == k && a.find(x) == a.end()) funz(i + 1);
    if (a.find(x) == a.end()) {
      ans++;
      a.insert(x);
    }
  }
  cout << ans;
}
