#include <bits/stdc++.h>
using namespace std;
int a[400005], n, b[400005], c[400005], k, vis[400005], ans, d;
multiset<int> s;
multiset<int>::iterator iter;
int main() {
  int i, j;
  scanf("%d %d", &n, &k);
  for (i = 1; i <= n; i++) scanf("%d", a + i);
  for (i = 1; i <= n; i++) b[i] = n + 1;
  for (i = n; i > 0; i--) {
    c[i] = b[a[i]];
    b[a[i]] = i;
  }
  for (i = 1; i <= n; i++) {
    if (s.find(i) != s.end()) {
      s.erase(i);
      s.insert(c[i]);
    } else {
      ans++;
      if (d < k) {
        d++;
        s.insert(c[i]);
      } else {
        iter = s.end();
        iter--;
        s.erase(iter);
        s.insert(c[i]);
      }
    }
  }
  cout << ans;
}
