#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long int n, k;
  cin >> n >> k;
  unordered_map<long long int, vector<long long int>> ind;
  set<pair<long long int, long long int>> now;
  vector<long long int> a(n);
  for (long long int i = 0; i < n; i++) {
    cin >> a[i];
    ind[a[i]].push_back(i);
  }
  for (auto& i : ind) reverse(i.second.begin(), i.second.end());
  long long int ans = 0;
  for (long long int i = 0; i < n; i++) {
    if (now.count({i, a[i]})) {
      now.erase({i, a[i]});
      ind[a[i]].pop_back();
      if (!ind[a[i]].empty()) now.insert({ind[a[i]].back(), a[i]});
    } else {
      ans++;
      if (now.size() == k) {
        auto it = (--now.end());
        now.erase(it);
      }
      ind[a[i]].pop_back();
      if (!ind[a[i]].empty()) now.insert({ind[a[i]].back(), a[i]});
    }
  }
  cout << ans;
  return 0;
}
