#include <bits/stdc++.h>
using namespace std;
int n, k;
int a[400000];
queue<int> q[400000];
set<int> s;
int res = 0;
int main() {
  cin >> n >> k;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    a[i]--;
    q[a[i]].push(i);
  }
  for (int i = 0; i < n; ++i) {
    q[a[i]].pop();
    if (s.count(i) == 0) {
      if (s.size() == k) s.erase(*(--s.end()));
      res++;
    }
    s.erase(i);
    if (q[a[i]].size() == 0)
      s.insert(1000000000 + i);
    else
      s.insert(q[a[i]].front());
  }
  cout << res << "\n";
}
