#include <bits/stdc++.h>
using namespace std;
vector<int> v[400002];
struct it {
  int index;
  bool operator<(const it& that) const {
    if (v[index].empty()) return 0;
    if (v[that.index].empty()) return 1;
    return v[index].back() < v[that.index].back();
  }
  it(int a) : index(a) {}
};
int m[400002];
bool book[400002] = {0};
int main() {
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    scanf("%d", &m[i]);
  }
  for (int i = n - 1; i >= 0; i--) v[m[i]].push_back(i);
  int num = 0;
  priority_queue<pair<int, int> > pq;
  for (int i = 0; i < n; i++) {
    v[m[i]].pop_back();
    if (book[m[i]] == 1) {
      if (v[m[i]].empty())
        pq.push(pair<int, int>(n, m[i]));
      else
        pq.push(pair<int, int>(v[m[i]].back(), m[i]));
      continue;
    }
    if (num < k) {
      num++;
      book[m[i]] = 1;
      if (v[m[i]].empty())
        pq.push(pair<int, int>(n, m[i]));
      else
        pq.push(pair<int, int>(v[m[i]].back(), m[i]));
    } else {
      num++;
      pair<int, int> top = pq.top();
      pq.pop();
      book[top.second] = 0;
      book[m[i]] = 1;
      if (v[m[i]].empty())
        pq.push(pair<int, int>(n, m[i]));
      else
        pq.push(pair<int, int>(v[m[i]].back(), m[i]));
    }
  }
  cout << num << endl;
}
