#include <bits/stdc++.h>
using namespace std;
const long long N = 400005;
vector<long long> nxt[N];
long long A[N];
void solve() {
  long long n, y, k;
  cin >> n >> k;
  for (__typeof((n)) i = (1); i <= (n); i++) cin >> A[i];
  for (__typeof((n)) i = (n); i >= (1); i--) {
    nxt[A[i]].push_back(i);
  }
  set<pair<long long, long long> > s;
  long long ans = 0;
  for (__typeof((n)) i = (1); i <= (n); i++) {
    long long x = A[i];
    nxt[x].pop_back();
    if (nxt[x].empty())
      y = 1000000007;
    else
      y = nxt[x].back();
    if (s.find({i, x}) == s.end()) {
      ans++;
      if (s.size() < k) {
        s.insert({y, x});
      } else {
        auto it = s.end();
        it--;
        s.erase(it);
        s.insert({y, x});
      }
    } else {
      s.erase(s.find({i, x}));
      s.insert({y, x});
    }
  }
  cout << ans << '\n';
}
signed main() {
  long long t;
  ios_base::sync_with_stdio(false);
  t = 1;
  while (t--) solve();
  return 0;
}
