#include <bits/stdc++.h>
using namespace std;
long long modexpo(long long x, long long p) {
  long long res = 1;
  x = x % 1000000007;
  while (p) {
    if (p % 2) res = res * x;
    p >>= 1;
    x = x * x % 1000000007;
    res %= 1000000007;
  }
  return res;
}
struct compare {
  bool operator()(const pair<long long, long long> a,
                  const pair<long long, long long> b) const {
    return a.first < b.first;
  }
};
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, k;
  cin >> n >> k;
  long long arr[n + 1];
  arr[0] = 0;
  map<long long, long long> mp;
  vector<long long> g[n + 5];
  for (long long i = 1; i <= n; i++) {
    cin >> arr[i];
    g[arr[i]].push_back(i);
    mp[arr[i]]++;
  }
  long long cur = 0;
  set<long long> have;
  long long ans = 0;
  for (long long i = 1; i <= n; i++) {
    if (have.find(arr[i]) != have.end()) {
      mp[arr[i]]--;
      if (mp[arr[i]] == 0) {
        mp.erase(arr[i]);
      }
      continue;
    }
    if (cur == k) {
      long long flag = 0, mx = 0;
      for (long long x : have) {
        if (!mp.count(x)) {
          flag = x;
          break;
        }
        auto temp = upper_bound(g[x].begin(), g[x].end(), i);
        mx = max(mx, *temp);
      }
      if (flag == 0) {
        have.erase(arr[mx]);
      } else {
        have.erase(flag);
      }
      ans++;
      have.insert(arr[i]);
      mp[arr[i]]--;
      if (mp[arr[i]] == 0) {
        mp.erase(arr[i]);
      }
    } else {
      ans++;
      have.insert(arr[i]);
      cur++;
      mp[arr[i]]--;
      if (mp[arr[i]] == 0) {
        mp.erase(arr[i]);
      }
    }
  }
  cout << ans << endl;
}
