#include <bits/stdc++.h>
using namespace std;
const int MAXN = 4e5 + 11;
int n, k, ans;
int arr[MAXN];
stack<int> bk[MAXN];
struct myComp {
  bool operator()(const int &a, const int &b) const {
    if (bk[a].empty() || bk[b].empty())
      return bk[a].empty() > bk[b].empty();
    else
      return bk[a].top() > bk[b].top();
  }
};
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; ++i) scanf("%d", arr + i);
  for (int i = n - 1; i >= 0; --i) bk[arr[i]].push(i);
  set<int, myComp> S;
  for (int i = 0; i < n; ++i) {
    if (S.count(arr[i]))
      S.erase(arr[i]);
    else {
      ++ans;
      if (S.size() == k) S.erase(S.begin());
    }
    bk[arr[i]].pop();
    S.insert(arr[i]);
  }
  printf("%d", ans);
  return 0;
}
