#include <bits/stdc++.h>
const int MAXN = 4e5 + 45;
using namespace std;
int a[MAXN], last[MAXN], nxt[MAXN], my_pair[MAXN];
set<pair<int, int>> s;
int main() {
  cin.sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i]--;
  }
  for (int i = 0; i < n; i++) {
    last[i] = n;
  }
  for (int i = n - 1; i >= 0; i--) {
    nxt[i] = last[a[i]];
    last[a[i]] = i;
  }
  int price = 0;
  for (int i = 0; i < n; i++) {
    auto it = s.find(make_pair(my_pair[a[i]], a[i]));
    if (it != s.end()) {
      price--;
      s.erase(it);
    }
    if (s.size() == k) {
      s.erase(s.begin());
    }
    price++;
    my_pair[a[i]] = -nxt[i];
    s.insert(make_pair(-nxt[i], a[i]));
  }
  cout << price << endl;
  return 0;
}
