#include <bits/stdc++.h>
using namespace std;
int inf_int = 1e9;
long long inf_ll = 1e17;
const double pi = 3.1415926535898;
const long long mod = 99990001;
const int MAXN = 5e3 + 10;
bool debug = false;
int a[MAXN];
int last[MAXN];
void solve() {
  int n, k;
  cin >> n >> k;
  set<int> s;
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  for (int i = 1; i <= n; ++i) {
    int x = a[i];
    if (s.find(x) == s.end()) {
      if (s.size() == k) {
        int mx = 0;
        int ind = -1;
        for (int v : s) {
          int cur = inf_int;
          for (int e = n; e >= i; --e) {
            if (a[e] == v) {
              cur = e;
            }
          }
          if (cur > mx) {
            mx = cur;
            ind = v;
          }
        }
        s.erase(ind);
      }
      s.insert(x);
      ans++;
    } else {
    }
  }
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) solve();
  return 0;
}
