#include <bits/stdc++.h>
int main() {
  std::ios_base::sync_with_stdio(false);
  int n, k;
  std::cin >> n >> k;
  std::vector<int> a(n);
  std::vector<std::queue<int> > reservations(n, std::queue<int>());
  for (int i = 0; i < n; i++) {
    int a_i;
    std::cin >> a_i;
    a[i] = a_i - 1;
    reservations[a_i - 1].push(i);
  }
  auto cmp = [](std::pair<int, int> a, std::pair<int, int> b) {
    return a.first > b.first;
  };
  std::set<std::pair<int, int>, decltype(cmp)> curr_books_prio(cmp);
  std::set<int> curr_books;
  int counter = 0;
  for (int i = 0; i < n; i++) {
    int book = a[i];
    if (curr_books.find(book) != curr_books.end()) {
      curr_books_prio.erase(std::prev(curr_books_prio.end()));
      reservations[book].pop();
      if (!reservations[book].empty()) {
        int time_next_reservation = reservations[book].front();
        curr_books_prio.insert(std::make_pair(time_next_reservation, book));
      } else {
        curr_books.erase(book);
      }
    } else {
      counter++;
      if (curr_books.size() >= k) {
        int to_remove = (*curr_books_prio.begin()).second;
        curr_books.erase(to_remove);
        curr_books_prio.erase(curr_books_prio.begin());
      }
      reservations[book].pop();
      if (!reservations[book].empty()) {
        int time_next_reservation = reservations[book].front();
        curr_books_prio.insert(std::make_pair(time_next_reservation, book));
        curr_books.insert(book);
      }
    }
  }
  std::cout << counter << std::endl;
  return 0;
}
