#include <bits/stdc++.h>
using namespace std;
const int N = 4e5 + 10;
const int INF = 1e9;
map<int, int> cnt;
vector<int> ind[N];
vector<int> pos(N, 0);
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    ind[a[i]].push_back(i);
  }
  for (int i = 0; i < n; i++) {
    ind[a[i]].push_back(INF);
  }
  set<pair<int, int> > s;
  set<int> inSet;
  int result = 0;
  for (int i = 0; i < n; i++) {
    int cur = a[i];
    pos[cur]++;
    if (inSet.find(cur) != inSet.end()) {
      s.erase(make_pair(ind[cur][pos[cur] - 1], cur));
      s.insert(make_pair(ind[cur][pos[cur]], cur));
      continue;
    }
    if (inSet.size() == k) {
      inSet.erase((*s.rbegin()).second);
      s.erase(*s.rbegin());
    }
    s.insert(make_pair(ind[cur][pos[cur]], cur));
    inSet.insert(cur);
    result++;
  }
  cout << result;
  return 0;
}
