#include <bits/stdc++.h>
using namespace std;
long long t, n, i, j, k, x, y, z, l, r, mid, mod = 1e9 + 7, g, m, ans;
long long a[400005], b[400005], c[400005];
char ch;
vector<long long> v[400005], u;
multiset<pair<int, int> > s;
int main() {
  ios::sync_with_stdio(NULL);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  for (i = 0; i < n; i++) cin >> a[i];
  for (i = 0; i <= n; i++) v[i].push_back(n);
  for (i = n - 1; i >= 0; i--) v[a[i]].push_back(i);
  for (i = 1; i <= k; i++) s.insert({-n - 1, i});
  for (i = 0; i < n; i++) {
    x = v[a[i]].size();
    if (b[a[i]]) {
      s.erase(s.find({-v[a[i]][x - 1], b[a[i]]}));
      v[a[i]].pop_back(), x--;
      s.insert({-v[a[i]][x - 1], b[a[i]]});
      continue;
    }
    ans++;
    y = s.begin()->second;
    s.erase(s.begin());
    b[c[y]] = 0;
    b[a[i]] = y;
    c[y] = a[i];
    if (x > 1) v[a[i]].pop_back(), x--;
    s.insert({-v[a[i]][x - 1], y});
  }
  cout << ans;
}
