#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  vector<int> a(n);
  vector<int> next(n, inf);
  vector<int> p(n, -1);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
    --a[i];
    if (p[a[i]] != -1) {
      next[p[a[i]]] = i;
    }
    p[a[i]] = i;
  }
  set<pair<int, int>> q;
  set<int> q2;
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    int cur = a[i];
    if (q2.find(cur) != q2.end()) {
      q2.erase(cur);
      q.erase({-i, cur});
    } else
      ++ans;
    if (q2.size() >= k) {
      int v = q.begin()->second;
      q2.erase(v);
      q.erase(q.begin());
    }
    q2.insert(cur);
    q.insert({-next[i], cur});
  }
  printf("%d", ans);
  return 0;
}
