#include <bits/stdc++.h>
using namespace std;
const int MAX_N = (int)4e5 + 5;
int ne[MAX_N], last[MAX_N], a[MAX_N];
set<int> cur;
int main() {
  int n, k, res = 0;
  scanf("%d%d", &n, &k);
  for (int i = 0; n - i; scanf("%d", &a[i++])) continue;
  for (int i = 1; n - i + 1; last[i++] = -1) continue;
  for (int i = n - 1; i + 1; last[a[i]] = i, i--)
    ne[i] = (last[a[i]] + 1 ? last[a[i]] : INT_MAX);
  for (int i = 0; n - i; i++)
    if (cur.count(i)) {
      cur.erase(i);
      cur.insert(ne[i]);
    } else if (cur.size() < k) {
      cur.insert(ne[i]);
      res++;
    } else {
      cur.erase(--cur.end());
      cur.insert(ne[i]);
      res++;
    }
  return printf("%d", res), 0;
  ;
}
