#include <bits/stdc++.h>
using namespace std;
const int MAXN = 400001;
vector<int> adj[MAXN];
int nxt[MAXN];
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  int a[n + 1];
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    adj[i].push_back(n + 1);
    adj[a[i]].push_back(i);
  }
  for (int i = 1; i <= n; i++) {
    sort(adj[i].begin(), adj[i].end());
    if (adj[i].size() > 1) {
      int k = adj[i].size();
      for (int j = 0; j < k - 1; j++) {
        nxt[adj[i][j]] = adj[i][j + 1];
      }
    }
  }
  set<pair<int, int>> requests;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (requests.find({i, a[i]}) != requests.end()) {
      requests.erase(requests.find({i, a[i]}));
      requests.insert({nxt[i], a[i]});
    } else {
      ans++;
      if (requests.size() < k) {
        requests.insert({nxt[i], a[i]});
      } else {
        auto it = requests.end();
        it--;
        requests.erase(it);
        requests.insert({nxt[i], a[i]});
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}
