#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 7;
signed main() {
  std::ios::sync_with_stdio(0);
  std::cin.tie(0);
  ;
  int n, k;
  cin >> n >> k;
  vector<int> a(n), lst(n, INF), nxt(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i]--;
  }
  for (int i = n - 1; i >= 0; i--) {
    nxt[i] = lst[a[i]];
    lst[a[i]] = i;
  }
  set<pair<int, int> > who;
  set<int> cur;
  int cost = 0;
  for (int i = 0; i < n; i++) {
    if (cur.count(a[i])) {
      who.erase({i, a[i]});
      who.insert({nxt[i], a[i]});
      continue;
    }
    cost++;
    if (who.size() == k) {
      int x = who.rbegin()->second;
      who.erase(*who.rbegin());
      cur.erase(x);
    }
    cur.insert(a[i]);
    who.insert({nxt[i], a[i]});
  }
  cout << cost << '\n';
}
