#include <bits/stdc++.h>
using namespace std;
class Solution {
  int n, k;
  vector<int> a;
  set<pair<int, int>> sto;
  vector<queue<int>> need;
  void grid() { sto.erase(prev(sto.end())); }

 public:
  void sol() {
    cin >> n >> k;
    a = vector<int>(n);
    need = vector<queue<int>>(n + 1);
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      need[a[i]].push(i);
    }
    for (int i = 0; i <= n; i++) need[i].push(n);
    sto = set<pair<int, int>>();
    int cost = 0;
    for (int i = 0; i < n; i++) {
      if (!need[a[i]].empty()) need[a[i]].pop();
      auto it = sto.find({i, a[i]});
      if (it != sto.end()) {
        sto.erase(it);
        sto.insert({need[a[i]].front(), a[i]});
        continue;
      } else {
        if (sto.size() == k) grid();
        sto.insert({need[a[i]].front(), a[i]});
        cost++;
      }
    }
    cout << cost;
  }
};
int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  Solution s;
  s.sol();
  return 0;
}
