#include <bits/stdc++.h>
using namespace std;
const int inf = 1E9;
const long long mod = 1LL;
int main() {
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  vector<vector<int> > appearance(n + 1, vector<int>());
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    appearance[a[i]].push_back(i + 1);
  }
  set<pair<int, int> > pq;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int pre = appearance[a[i]][0];
    appearance[a[i]].erase(appearance[a[i]].begin());
    if (pq.find({-pre, a[i]}) == pq.end()) {
      if (pq.size() == k) {
        pq.erase(pq.begin());
      }
      ans++;
    } else {
      pq.erase(pq.find({-pre, a[i]}));
    }
    pq.insert({appearance[a[i]].size() == 0 ? -100000000 : -appearance[a[i]][0],
               a[i]});
  }
  cout << ans << endl;
  return 0;
}
