#include <bits/stdc++.h>
using namespace std;
const int MAXN = 400000;
int nex[MAXN + 10], pre[MAXN + 10], a[MAXN + 10];
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  set<pair<int, int> > st;
  memset(nex, 0x3f, sizeof nex);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    if (pre[a[i]]) nex[pre[a[i]]] = i;
    pre[a[i]] = i;
  }
  int cost = 0;
  for (int i = 1; i <= n; i++) {
    if (st.find(make_pair(i, a[i])) != st.end()) {
      st.erase(make_pair(i, a[i]));
      st.insert(make_pair(nex[i], a[i]));
      continue;
    }
    cost++;
    if ((int)st.size() == k) {
      set<pair<int, int> >::iterator iter = st.end();
      iter--;
      st.erase(iter);
    }
    st.insert(make_pair(nex[i], a[i]));
  }
  printf("%d\n", cost);
  return 0;
}
