#include <bits/stdc++.h>
using namespace std;
const int N = 400005;
int n, k;
int a[N];
int hh[N];
int h[N];
int ans;
bool c[N];
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  for (int i = 1; i <= n; ++i) hh[i] = N;
  for (int i = n; i >= 1; --i) {
    h[i] = hh[a[i]];
    hh[a[i]] = i;
  }
  set<pair<int, int> > q;
  for (int i = 1; i <= n; ++i) {
    if (c[a[i]] == true) {
      q.erase(q.begin());
      q.insert(make_pair(h[i], a[i]));
      continue;
    }
    if (q.size() >= k) {
      c[(--q.end())->second] = false;
      q.erase((--q.end()));
    }
    ++ans;
    c[a[i]] = true;
    q.insert(make_pair(h[i], a[i]));
  }
  cout << ans << endl;
  return 0;
}
