#include <bits/stdc++.h>
using namespace std;
template <typename T>
bool chmax(T& a, const T& b) {
  return a < b ? (a = b, true) : false;
}
template <typename T>
bool chmin(T& a, const T& b) {
  return b < a ? (a = b, true) : false;
}
int N, K;
const int INF = 1e9;
int main() {
  scanf("%d%d", &N, &K);
  vector<int> A(N);
  for (int i = (int)(0); i < (int)(N); i++) {
    scanf("%d", &A[i]);
  }
  vector<int> nxt(N), last(N + 1, -1);
  for (int i = N - 1; i >= 0; i--) {
    if (last[A[i]] == -1) {
      nxt[i] = INF;
    } else {
      nxt[i] = last[A[i]];
    }
    last[A[i]] = i;
  }
  int ans = 0;
  set<pair<int, int> > st;
  for (int i = (int)(0); i < (int)(N); i++) {
    if (st.lower_bound(make_pair(i, A[i])) !=
        st.upper_bound(make_pair(i, A[i]))) {
      st.erase(make_pair(i, A[i]));
      st.insert(make_pair(nxt[i], A[i]));
    } else {
      while (st.size() > K - 1) {
        st.erase(--st.end());
      }
      st.insert(make_pair(nxt[i], A[i]));
      ans++;
    }
  }
  printf("%d\n", ans);
  return 0;
}
