#include <bits/stdc++.h>
using namespace std;
int N, K, arr[400011], nxt[400011], last[400011];
bool in[400011];
int num, cost;
priority_queue<int> del;
int main() {
  if (fopen("data.in", "r")) freopen("data.in", "r", stdin);
  scanf("%d", &N);
  scanf("%d", &K);
  memset(last, -1, sizeof(last));
  for (int i = 0; i < N; i++) {
    scanf("%d", &arr[i]);
    nxt[i] = ((1 << 29) + 123);
    if (last[arr[i]] != -1) nxt[last[arr[i]]] = i;
    last[arr[i]] = i;
  }
  for (int i = 0; i < N; i++) {
    if (!in[arr[i]]) {
      if (num >= K) {
        if (del.top() < N) in[arr[del.top()]] = false;
        del.pop();
        num--;
      }
      del.push(nxt[i]);
      in[arr[i]] = true;
      cost++, num++;
    } else if (in[arr[i]]) {
      del.push(nxt[i]);
    }
  }
  printf("%d\n", cost);
  return 0;
}
