#include <bits/stdc++.h>
using namespace std;
const int maxn = int(4e5) + 5;
int A[maxn], last[maxn], nex[maxn];
int main(void) {
  int n, k, res = 0;
  scanf("%d%d", &n, &k);
  for (int i = 0; i < maxn; i++) last[i] = -1, nex[i] = maxn + 1;
  for (int i = 0; i < n; i++) {
    scanf("%d", &A[i]);
    if (last[A[i]] != -1) nex[last[A[i]]] = i;
    last[A[i]] = i;
  }
  set<pair<int, int>> cur;
  for (int i = 0; i < n; i++) {
    if (cur.find({i, A[i]}) == cur.end()) {
      res++;
      while (int(cur.size()) >= k) cur.erase(*cur.rbegin());
      cur.insert({nex[i], A[i]});
    } else {
      cur.erase({i, A[i]});
      cur.insert({nex[i], A[i]});
    }
    if (last[A[i]] == i) cur.erase({nex[i], A[i]});
  }
  printf("%d\n", res);
}
