#include <bits/stdc++.h>
using namespace std;
const int maxn = 400005;
struct node {
  int x, nxt;
  friend bool operator<(node A, node B) { return A.nxt < B.nxt; }
};
priority_queue<node> que;
vector<int> vec[maxn];
int N, K, have[maxn], a[maxn], len[maxn];
void do_it(int x) {
  node T;
  while (que.size()) {
    T = que.top();
    que.pop();
    if (have[T.x]) {
      have[T.x] = 0;
      have[x] = 1;
      return;
    }
  }
}
int main(void) {
  int i, j, n, m, ans;
  node T;
  scanf("%d %d", &n, &K);
  for (i = 0; i < n; i++) {
    vec[i].clear();
    len[i] = 0;
  }
  for (i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    vec[a[i]].push_back(i);
  }
  N = 0;
  ans = 0;
  while (que.size()) que.pop();
  for (i = 0; i < n; i++) {
    if (have[a[i]] == 0) {
      ans++;
      if (N < K) {
        have[a[i]] = 1;
        N++;
      } else {
        do_it(a[i]);
      }
    }
    len[a[i]]++;
    T.x = a[i];
    if (vec[a[i]].size() == len[a[i]]) {
      T.nxt = 700000;
    } else {
      T.nxt = vec[a[i]][len[a[i]]];
    }
    que.push(T);
  }
  cout << ans << endl;
}
