#include <bits/stdc++.h>
using namespace std;
const int MAX = 500000;
int a[MAX], last[MAX], prv[MAX], inSet[MAX], current[MAX];
int n, k;
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> k;
  memset(last, -1, sizeof(last));
  memset(prv, -1, sizeof(prv));
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    prv[i] = last[a[i]];
    last[a[i]] = i;
  }
  set<pair<int, int> > s;
  int ans = 0;
  for (int i = n - 1; i >= 0; i--) {
    int cur = a[i];
    if (inSet[cur]) {
      s.erase(s.find(make_pair(current[cur], cur)));
      s.insert(make_pair(prv[i], cur));
      current[cur] = prv[i];
      continue;
    }
    ans++;
    if (s.size() < k) {
      inSet[cur] = true;
      s.insert(make_pair(prv[i], cur));
      current[cur] = prv[i];
    } else {
      pair<int, int> fr = (*s.begin());
      inSet[cur] = true;
      inSet[fr.second] = false;
      s.erase(s.begin());
      s.insert(make_pair(prv[i], cur));
      current[cur] = prv[i];
    }
  }
  cout << ans << '\n';
  return 0;
}
