#include <bits/stdc++.h>
using namespace std;
const int N = 400005;
int a[N], nxt[N], idx[N];
pair<bool, int> vis[N];
int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = n - 1; i >= 0; i--) {
    if (idx[a[i]] == 0) {
      nxt[i] = 1e9;
    } else {
      nxt[i] = idx[a[i]];
    }
    idx[a[i]] = i;
  }
  set<pair<int, int> > st;
  int res = 0;
  for (int i = 0; i < n; i++) {
    if (!vis[a[i]].first) {
      if ((int)st.size() == k) {
        auto it = st.end();
        --it;
        vis[it->second].first = false;
        st.erase(it);
      }
      vis[a[i]].first = true;
      vis[a[i]].second = nxt[i];
      st.insert({nxt[i], a[i]});
      ++res;
    } else {
      st.erase({vis[a[i]].second, a[i]});
      st.insert({nxt[i], a[i]});
      vis[a[i]].second = nxt[i];
    }
  }
  printf("%d", res);
  return 0;
}
