#include <bits/stdc++.h>
using namespace std;
const int N = 4e5 + 22;
int n, k, r, a[N], lst[N], t[N];
set<int> s;
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = n; i >= 1; i--) {
    if (lst[a[i]] == 0)
      t[i] = N;
    else
      t[i] = lst[a[i]];
    lst[a[i]] = i;
  }
  for (int i = 1; i <= n; i++) {
    if (s.find(i) != s.end()) {
      s.erase(i);
      s.insert(t[i]);
      continue;
    }
    r++;
    if (s.size() < k) {
      s.insert(t[i]);
      continue;
    }
    set<int>::iterator it = s.end();
    it--;
    s.erase(it);
    s.insert(t[i]);
  }
  cout << r;
  return 0;
}
