#include <bits/stdc++.h>
using namespace std;
const int N = 4e5 + 5;
map<int, int> idx;
set<int> s;
int a[N], nx[N];
int main() {
  ios::sync_with_stdio(0);
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int i = n - 1; i >= 0; --i) {
    auto it = idx.find(a[i]);
    if (it == idx.end())
      nx[i] = n;
    else
      nx[i] = it->second;
    idx[a[i]] = i;
  }
  int c = 0;
  for (int i = 0; i < n; ++i) {
    if (s.count(i)) {
      s.erase(i);
      s.insert(nx[i]);
      continue;
    }
    if (s.size() == k) s.erase(--s.end());
    s.insert(nx[i]);
    ++c;
  }
  cout << c << '\n';
  return 0;
}
