#include <bits/stdc++.h>
using namespace std;
struct dat {
  int id, v;
  bool operator<(const dat& x) const { return v < x.v; }
};
priority_queue<dat> q;
int n, k;
int a[400001];
int r[400001];
int has[400001];
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
    has[i] = n + 1;
  }
  for (int i = n; i >= 1; --i) {
    r[i] = has[a[i]];
    has[a[i]] = i;
  }
  for (int i = 1; i <= n; ++i) has[i] = 0;
  int as = 0, nowsz = 0;
  for (int i = 1; i <= n; ++i) {
    if (!has[a[i]]) {
      ++as;
      if (nowsz < k) {
        ++nowsz;
      } else {
        dat p = q.top();
        q.pop();
        has[p.id] = 0;
      }
      has[a[i]] = 1;
    }
    q.push((dat){a[i], r[i]});
  }
  printf("%d\n", as);
  return 0;
}
