#include <bits/stdc++.h>
using namespace std;
void dropAny(const vector<int> &a, int offset, vector<bool> &used) {
  vector<int> next(used.size(), a.size());
  for (int i = int(a.size()) - 1; i >= offset; --i) {
    next[a[i]] = i;
  }
  int best = -1;
  for (int i = 0; i < (int)used.size(); ++i) {
    if (!used[i]) {
      continue;
    }
    if (best == -1 || next[best] < next[i]) {
      best = i;
    }
  }
  used[best] = false;
  ;
}
struct RangeTree {
  int kk;
  vector<pair<int, int> > b;
  RangeTree(int n) {
    kk = 1;
    while (kk < n) {
      kk *= 2;
    }
    b.assign(2 * kk + 10, pair<int, int>(-1, -1));
  }
  int getMaxPos() { return b[1].second; }
  int get(int pos) { return b[pos + kk].first; }
  void set(int pos, int val) {
    ;
    int t = pos + kk;
    b[t] = pair<int, int>(val, pos);
    while (t > 1) {
      t /= 2;
      b[t] = max(b[2 * t], b[2 * t + 1]);
    }
  }
};
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  int maxA = 0;
  vector<int> a(n);
  vector<pair<int, int> > z(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
    z[i] = pair<int, int>(a[i], i);
    maxA = max(maxA, a[i] + 1);
  }
  sort(z.begin(), z.end());
  vector<int> next(n, n);
  for (int i = 1; i < int(z.size()); ++i) {
    if (z[i - 1].first == z[i].first) {
      next[z[i - 1].second] = z[i].second;
    }
  }
  for (int i = 0; i < n; ++i) {
    ;
  };
  RangeTree tree(maxA);
  int cnt = 0;
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    if (tree.get(a[i]) == -1) {
      ;
      if (cnt == k) {
        int pos = tree.getMaxPos();
        ;
        tree.set(pos, -1);
        cnt--;
      }
      tree.set(a[i], next[i]);
      ans++;
      cnt++;
    } else {
      tree.set(a[i], next[i]);
    }
  }
  printf("%d\n", ans);
  return 0;
}
