#include <bits/stdc++.h>
using namespace std;
long long INF = 1e18;
const int MOD = 1e9 + 7;
int a[800005], nxt[800005], usedm[800005];
int main() {
  ios_base::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--) {
    if (!usedm[a[i]]) {
      usedm[a[i]] = i;
      nxt[i] = MOD;
    } else {
      nxt[i] = usedm[a[i]];
      usedm[a[i]] = i;
    }
  }
  set<int> data;
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    if (data.find(i) != data.end()) {
      data.erase(i);
      data.insert(nxt[i]);
    } else {
      if (data.size() < k) {
        data.insert(nxt[i]);
      } else {
        data.erase(--data.end());
        data.insert(nxt[i]);
      }
      cnt++;
    }
  }
  cout << cnt;
  return 0;
}
