#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);
  int n, k;
  cin >> n >> k;
  auto a = vector<int>(n);
  for (int i = 0; i < (n); ++i) cin >> a[i];
  auto next_pos = vector<deque<int>>(n);
  for (int i = 0; i < (n); ++i) {
    auto book = a[i] - 1;
    next_pos[book].push_back(i);
  }
  for (int i = 0; i < (n); ++i) next_pos[i].push_back(n);
  set<pair<int, int>> books;
  auto buys = 0;
  for (int i = 0; i < (n); ++i) {
    auto book = a[i] - 1;
    next_pos[book].pop_front();
    if (books.count({i, book}) > 0) {
      books.erase({i, book});
      books.insert({next_pos[book].front(), book});
      continue;
    }
    if (books.size() == k) {
      books.erase(prev(books.end()));
    }
    buys++;
    books.insert({next_pos[book].front(), book});
  }
  cout << buys << '\n';
  cout.flush();
  return 0;
}
