#include <bits/stdc++.h>
using namespace std;
int a[400010], ans = 0;
set<int> has;
queue<int> qs[400010];
priority_queue<pair<int, int> > pq;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    qs[a[i]].push(i);
  }
  for (int i = 0; i < n; i++) {
    int x = a[i];
    qs[x].pop();
    if (has.find(x) != has.end()) {
      if (qs[x].empty()) {
        has.erase(x);
      } else {
        pq.push(make_pair(qs[x].front(), x));
      }
    } else {
      ans++;
      int rm = -1;
      if (has.size() == k) {
        while (!pq.empty() &&
               (has.find(pq.top().second) == has.end() || pq.top().first < i)) {
          pq.pop();
        }
        rm = pq.top().second;
        while (!pq.empty() &&
               (has.find(pq.top().second) == has.end() || pq.top().first < i)) {
          pq.pop();
        }
      }
      if (has.find(rm) != has.end()) {
        has.erase(rm);
      }
      if (!qs[x].empty()) {
        has.insert(x);
        pq.push(make_pair(qs[x].front(), x));
      }
    }
  }
  cout << ans << endl;
  return 0;
}
