#include <bits/stdc++.h>
using namespace std;
long long min(long long a, long long b) {
  if (a < b) return a;
  return b;
}
int n, k;
int a[211111];
int nx[211111];
int b[211111];
bool used[211111];
int main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i]--;
    used[i] = false;
    b[i] = n + 1;
  }
  for (int i = n - 1; i >= 0; i--) {
    nx[i] = b[a[i]];
    b[a[i]] = i;
  }
  int t = 0;
  int money = 0;
  set<pair<int, int> > s;
  for (int i = 0; i < n; i++) {
    if (used[a[i]]) {
      s.erase(s.find(make_pair(-i, a[i])));
      s.insert(make_pair(-nx[i], a[i]));
      continue;
    }
    if (t == k) {
      int ad = (*s.begin()).second;
      s.erase(s.begin());
      used[ad] = false;
      t--;
    }
    used[a[i]] = true;
    t++;
    money++;
    s.insert(make_pair(-nx[i], a[i]));
  }
  cout << money;
  return 0;
}
