#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> A(n);
  vector<int> N(n), C(n, n);
  for (int i = 0; i < n; i++) {
    cin >> A[i];
    A[i]--;
  }
  for (int i = n - 1; i >= 0; i--) {
    N[i] = C[A[i]];
    C[A[i]] = i;
  }
  set<int> s;
  set<pair<int, int> > q;
  int res = 0;
  for (int i = 0; i < n; i++) {
    if (s.size() < k) {
      if (s.find(A[i]) == s.end()) {
        res++;
        s.insert(A[i]);
        q.insert(make_pair(N[i], A[i]));
      } else {
        q.erase(make_pair(i, A[i]));
        q.insert(make_pair(N[i], A[i]));
      }
    } else {
      if (s.find(A[i]) == s.end()) {
        pair<int, int> curr = *(--q.end());
        int who = curr.second;
        s.erase(who);
        res++;
        q.erase(curr);
        q.insert(make_pair(N[i], A[i]));
        s.insert(A[i]);
      } else {
        q.erase(make_pair(i, A[i]));
        q.insert(make_pair(N[i], A[i]));
      }
    }
  }
  cout << res << endl;
  return 0;
}
