#include <bits/stdc++.h>
using namespace std;
const int N = 4e5 + 10;
int a[N];
vector<int> v[N];
set<pair<int, int> > s;
set<pair<int, int> >::iterator it;
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i <= n; i++) v[i].push_back(n);
  for (int i = n - 1; i >= 0; i--) {
    v[a[i]].push_back(i);
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    it = s.find(make_pair(-i, a[i]));
    v[a[i]].pop_back();
    if (it != s.end()) {
      s.erase(it);
      s.insert(make_pair(-v[a[i]].back(), a[i]));
      continue;
    }
    ans++;
    if (s.size() == k) {
      s.erase(s.begin());
    }
    s.insert(make_pair(-v[a[i]].back(), a[i]));
  }
  cout << ans << "\n";
  return 0;
}
