#include <bits/stdc++.h>
using namespace std;
int arr[400001];
set<int> bookOnIndices[400001];
int main() {
  int n, k;
  cin >> n >> k;
  set<int> books;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    bookOnIndices[arr[i]].insert(i);
  }
  set<pair<int, int> > library;
  int res = 0;
  for (int j = 0; j < n; j++) {
    int currentNeededBook = arr[j];
    pair<int, int> curPair;
    curPair.first = -*bookOnIndices[currentNeededBook].lower_bound(j);
    curPair.second = currentNeededBook;
    if (library.find(curPair) == library.end()) {
      if (library.size() == k) {
        library.erase(library.begin());
      }
      res++;
      pair<int, int> newpair;
      if (bookOnIndices[currentNeededBook].upper_bound(j) ==
          bookOnIndices[currentNeededBook].end()) {
        newpair.first = INT_MIN;
      } else
        newpair.first = -*bookOnIndices[currentNeededBook].upper_bound(j);
      newpair.second = currentNeededBook;
      library.insert(newpair);
    } else {
      library.erase(curPair);
      if (bookOnIndices[currentNeededBook].upper_bound(j) ==
          bookOnIndices[currentNeededBook].end()) {
        curPair.first = INT_MIN;
      } else
        curPair.first = -*bookOnIndices[currentNeededBook].upper_bound(j);
      library.insert(curPair);
    }
  }
  cout << res << endl;
  return 0;
}
