#include <bits/stdc++.h>
using namespace std;
class TaskA {
 public:
  void solve(std::istream& in, std::ostream& out) {
    int n, k;
    in >> n >> k;
    vector<int> a(n);
    vector<int> cnt(n + 1);
    vector<vector<int> > pos(n + 1);
    set<pair<int, int> > c;
    for (int i = 0; i < n; i++) {
      in >> a[i];
      pos[a[i]].push_back(i);
      cnt[a[i]]++;
    }
    for (int i = 1; i <= n; i++) {
      reverse(pos[i].begin(), pos[i].end());
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
      bool good = 0;
      if (!c.count({i, a[i]})) {
        good = 1;
        ans++;
      }
      c.erase({pos[a[i]].back(), a[i]});
      pos[a[i]].pop_back();
      if (c.size() == k && good) {
        c.erase(--c.end());
      }
      if (!pos[a[i]].empty()) {
        c.insert({pos[a[i]].back(), a[i]});
      }
    }
    out << ans << '\n';
  }
};
int main() {
  ios::sync_with_stdio(0);
  TaskA solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}
