"use strict"

function main(input) {
  input = input.split(/\n|\s/).map(v => ~~v)
  const n = input[0]
  const k = input[1]
  const nums = input.slice(2, -1).sort((a, b) => a - b)

  let items = []
  let ans = 0
  let pointer = null
  for (let i = 0; i < nums.length; i++) {
    if (
      i == 0 ||
      items[pointer].key == undefined ||
      items[pointer].key != nums[i]
    ) {
      pointer = pointer === null ? 0 : pointer + 1
      items[pointer] = { key: nums[i], count: 1 }
    } else {
      items[pointer].count += 1
    }
  }

  // sort by count
  items.sort((a, b) => {
    return a.count - b.count
  })

  if (k <= items.length) {
    const diff = items.length - k
    const tar = items.slice(0, diff)
    if (diff > 1) {
      ans = tar.reduce((a, b) => a.count + b.count)
    } else {
      ans = items[0].count
    }
  }

  console.log(ans)
}
main(require("fs").readFileSync("/dev/stdin", "utf8"))