#include <bits/stdc++.h>
using namespace std;
int ar[400015];
int nxt[400015];
map<int, int> mp;
bool vis[400015];
int main() {
  int i, j, N, K, money = 0, cnt = 0;
  scanf("%d%d", &N, &K);
  for (i = 1; i <= N; i++) {
    scanf("%d", &ar[i]);
    mp[ar[i]] = N + 1;
  }
  for (i = N; i >= 1; i--) {
    int num = ar[i];
    nxt[i] = mp[num];
    mp[num] = i;
  }
  priority_queue<pair<int, int> > pq;
  for (i = 1; i <= N; i++) {
    int num = ar[i];
    if (vis[num]) {
      pq.push(pair<int, int>(nxt[i], num));
      continue;
    }
    money++;
    if (cnt == K) {
      pair<int, int> p = pq.top();
      pq.pop();
      cnt--;
      vis[p.second] = false;
    }
    if (nxt[i] <= N) {
      pq.push(pair<int, int>(nxt[i], num));
      cnt++;
      vis[num] = true;
    }
  }
  printf("%d\n", money);
  return 0;
}
