#include <bits/stdc++.h>
using namespace std;
int n, k, lis[400010];
int nx[400010], vis[400010];
int main() {
  memset(vis, -1, sizeof vis);
  int i;
  scanf("%d%d", &n, &k);
  for (i = 0; i < n; i++) scanf("%d", &lis[i]);
  for (i = n - 1; i >= 0; i--) {
    nx[i] = vis[lis[i]];
    vis[lis[i]] = i;
  }
  memset(vis, 0, sizeof vis);
  int ct = 0, ans = 0;
  priority_queue<pair<int, int> > pq;
  for (i = 0; i < n; i++) {
    if (vis[lis[i]]) {
      if (nx[i] != -1) {
        vis[lis[i]] = nx[i];
        pq.push(make_pair(nx[i], lis[i]));
      } else {
        vis[lis[i]] = n + 1;
        pq.push(make_pair(n + 1, lis[i]));
      }
    } else {
      ans++;
      if (ct < k) {
        ct++;
        if (nx[i] != -1) {
          vis[lis[i]] = nx[i];
          pq.push(make_pair(nx[i], lis[i]));
        } else {
          vis[lis[i]] = n + 1;
          pq.push(make_pair(n + 1, lis[i]));
        }
        continue;
      }
      while (pq.top().first != vis[pq.top().second]) pq.pop();
      int b = pq.top().second;
      pq.pop();
      vis[b] = 0;
      if (nx[i] != -1) {
        vis[lis[i]] = nx[i];
        pq.push(make_pair(nx[i], lis[i]));
      } else {
        vis[lis[i]] = n + 1;
        pq.push(make_pair(n + 1, lis[i]));
      }
    }
  }
  printf("%d\n", ans);
}
