#include <bits/stdc++.h>
int main() {
  long int N = 0, K = 0, i, j = 0, k = 0, count = 0, MAXin = 0, set = 0,
           sum = 0;
  scanf("%ld %ld", &N, &K);
  long A[N];
  long MAX[N];
  long Serect[N];
  for (i = 0; i < N; i++) {
    MAX[i] = 0;
    Serect[i] = 0;
  }
  for (i = 0; i < N; i++) {
    scanf("%ld", &A[i - count]);
    k = i - count;
    for (j = 0; j < i - count; j++) {
      if (A[j] == A[i - count]) {
        count++;
        k = j;
      }
    }
    MAX[k]++;
  }
  for (j = 0; j < K; j++) {
    MAXin = MAX[N - 1];
    for (i = 0; i < N; i++) {
      if (MAX[i] > MAXin && Serect[i] == 0) {
        MAXin = MAX[i];
        set = i;
      }
    }
    Serect[set]++;
  }
  for (i = 0; i < N; i++) {
    if (Serect[i] == 0) {
      sum = sum + MAX[i];
    }
  }
  printf("%ld", sum);
  return 0;
}
