#include <bits/stdc++.h>
using namespace std;
const int MAXN = 400000 + 100, INF = MAXN + 100;
int n, k, a[MAXN], in, ans;
set<int> w;
vector<int> g[MAXN];
int main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i <= n; i++) {
    g[i].push_back(INF);
  }
  for (int i = n - 1; i >= 0; i--) {
    g[a[i]].push_back(i);
  }
  priority_queue<pair<int, int> > q;
  for (int i = 0; i < n; i++) {
    if (w.count(a[i])) {
      g[a[i]].pop_back();
      q.push({g[a[i]][g[a[i]].size() - 1], a[i]});
    } else {
      ans++;
      g[a[i]].pop_back();
      if (w.size() == k) {
        while (!w.count(q.top().second)) {
          q.pop();
        }
        w.erase(q.top().second);
        q.pop();
      }
      w.insert(a[i]);
      q.push({g[a[i]][g[a[i]].size() - 1], a[i]});
    }
  }
  cout << ans;
  return 0;
}
