#include <bits/stdc++.h>
using namespace std;
const int N = 400007, inf = 1e9;
int n, k, a[N], nxt, ans;
vector<int> g[N];
set<pair<int, int> > st;
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    g[a[i]].push_back(i);
  }
  for (int i = 1; i <= n; i++) {
    g[i].push_back(inf);
  }
  for (int i = 1; i <= n; i++) {
    if (st.count(make_pair(-i, a[i]))) {
      st.erase(make_pair(-i, a[i]));
    } else {
      ans++;
    }
    if (st.size() == k) {
      st.erase(st.begin());
    }
    nxt = *upper_bound(g[a[i]].begin(), g[a[i]].end(), i);
    if (nxt != inf) {
      st.insert(make_pair(-nxt, a[i]));
    }
  }
  cout << ans;
  return 0;
}
