Solution explained with diagrams.
Approach\n\n\n# Code\n\nclass Solution:\n    def minimumDeletions(self, word: str, k: int) -> int:\n        counts = Counter(word)\n        values = list(sorted
# Approach\n![3085.png](https://assets.leetcode.com/users/images/ef773042-2589-4b67-b4e0-1b2d9a359354_1718942518.1501184.png)\n\n# Code\n```\nclass Solution:\n    def minimumDeletions(self, word: str, k: int) -> int:\n        counts = Counter(word)\n        values = list(sorted(counts.values(), reverse=True))\n\n        def f(i):\n            if i < 0:\n                return 0\n\n            curr_ans = 0\n            for x in range(i):\n                curr_ans += max(0, values[x] - (values[i] + k))\n            \n            return min(curr_ans, f(i-1)+values[i])\n\n        return f(len(values)-1)\n```
['Python3']