#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
bool dentro[410000];
int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  int vazio = 0;
  int v[n];
  vector<int> proximo(n, inf);
  vector<int> mapa(n, -1);
  for (int i = 0; i < n; i++) {
    scanf("%d", &v[i]);
    if (mapa[v[i]] != -1) {
      proximo[mapa[v[i]]] = i;
    }
    mapa[v[i]] = i;
  }
  int resp = 0;
  priority_queue<pair<int, int> > q;
  int qt = 0;
  for (int i = 0; i < n; i++) {
    if (dentro[v[i]]) {
      q.push(pair<int, int>(proximo[i], v[i]));
      continue;
    }
    if (qt < k) {
      q.push(pair<int, int>(proximo[i], v[i]));
      qt++;
      dentro[v[i]] = true;
      resp++;
      continue;
    }
    pair<int, int> aux = q.top();
    q.pop();
    resp++;
    int u = aux.second;
    dentro[u] = false;
    dentro[v[i]] = true;
    q.push(pair<int, int>(proximo[i], v[i]));
  }
  printf("%d\n", resp);
  return 0;
}
