#include <bits/stdc++.h>
using namespace std;
int main() {
  set<int> books;
  deque<int> requests[4001];
  int request[400000];
  int n;
  int k;
  cin >> n;
  cin >> k;
  int total = 0;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    requests[a].push_back(i);
    request[i] = a;
  }
  for (int i = 0; i < n; i++) {
    if (books.count(request[i]))
      i = i;
    else if (books.size() < k) {
      total++;
      books.insert(request[i]);
    } else {
      int max = -1;
      int bookToRemove = -1;
      bool empty = false;
      for (int book : books) {
        if (requests[book].size() == 0) {
          books.erase(book);
          empty = true;
          break;
        } else if (requests[book].front() > max) {
          max = requests[book].front();
          bookToRemove = book;
        }
      }
      if (!empty) books.erase(bookToRemove);
      books.insert(request[i]);
      total++;
    }
    requests[request[i]].pop_front();
  }
  cout << total;
}
