#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long int LINF = 0x3f3f3f3f3f3f3f3fll;
const long double pi = acos(-1);
const int MOD = 1e9 + 7;
const int N = 4e5 + 100;
int v[N];
vector<int> g[N];
set<int> pq;
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) scanf("%d", &v[i]);
  for (int i = 1; i <= n; i++) g[v[i]].push_back(i);
  for (int i = 1; i <= n; i++) g[i].push_back(n + 1 + i);
  int r = 0;
  for (int i = 1; i <= n; i++) {
    int nx = *upper_bound(g[v[i]].begin(), g[v[i]].end(), i);
    if (pq.count(i)) {
      pq.erase(i);
      pq.insert(nx);
    } else {
      r++;
      if (pq.size() < k) {
        pq.insert(nx);
      } else {
        pq.erase(--pq.end());
        pq.insert(nx);
      }
    }
  }
  cout << r << endl;
  return 0;
}
