#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  while (t--) {
    long long n, k;
    cin >> n >> k;
    long long a[n];
    long long ans = 0;
    for (long long i = 0; i < n; i++) cin >> a[i];
    map<long long, long long> cnt;
    for (long long i = 0; i < n; i++) cnt[a[i]]++;
    long long y = *max_element(a, a + n);
    bool have[n + 1];
    memset(have, false, sizeof(have));
    long long curr = 0;
    long long left[y + 1][n];
    for (long long i = 0; i <= y; i++) {
      for (long long j = 0; j < n; j++) left[i][j] = INT_MAX;
    }
    left[a[n - 1]][n - 1] = n - 1;
    for (long long i = 1; i <= y; i++) {
      for (long long j = n - 2; j >= 0; j--) {
        left[i][j] = left[i][j + 1];
        if (a[j] == i) left[i][j] = j;
      }
    }
    for (long long i = 0; i < n; i++) {
      if (have[a[i]]) continue;
      if (curr < k) {
        have[a[i]] = 1;
        curr++;
        ans++;
      } else {
        long long oxx = -1;
        long long ind = -1;
        for (long long j = 1; j <= y; j++) {
          if (left[j][i] > oxx && have[j]) {
            oxx = left[j][i];
            ind = j;
          }
        }
        have[ind] = 0;
        have[a[i]] = 1;
        ans++;
      }
    }
    cout << ans << endl;
  }
}
