#include <bits/stdc++.h>
using namespace std;
int n, m, a[500005], ans, k, b[500005], vis[500005];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++) {
    if (!vis[a[i]]) {
      if (k < m)
        b[++k] = a[i];
      else {
        int maxx = 0, w = 0, ww;
        for (int j = 1; j <= k; j++) {
          int s = 0;
          for (int kk = i; kk <= n; kk++)
            if (b[j] == a[kk]) {
              if (maxx < kk) maxx = kk, ww = j;
              s = 1;
              break;
            }
          if (s == 0) {
            w = 1;
            vis[b[j]] = 0;
            b[j] = a[i];
            break;
          }
        }
        if (w == 0) vis[b[ww]] = 0, b[ww] = a[i];
      }
      ans++;
      vis[a[i]] = 1;
    }
  }
  cout << ans;
  return 0;
}
