#include <bits/stdc++.h>
using namespace std;
long long a[1005], e[1005], n, k, cnt, maxx, maxxx, ans;
map<long long, bool> x;
int main() {
  scanf("%lld%lld", &n, &k);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++) {
    maxx = 0, maxxx = -1;
    if (x[a[i]]) continue;
    if (cnt < k)
      cnt++, x[a[i]] = true, ans++;
    else {
      memset(e, 0, sizeof e);
      for (int j = 1; j <= n; j++)
        if (x[j]) e[j] = 100;
      for (int j = 1; j <= n; j++)
        if (x[j])
          for (int k = i + 1; k <= n; k++)
            if (a[k] == j) {
              e[j] = k;
              break;
            }
      for (int j = 1; j <= n; j++)
        if (e[j] > maxx) maxx = e[j], maxxx = j;
      x[maxxx] = 0, x[a[i]] = 1, ans++;
    }
  }
  printf("%lld", ans);
  return 0;
}
