LCC '22 Contest 1 J2 - Halloween Harvest

View as PDF

Submit solution

Points: 5
Time limit: 1.0s
Memory limit: 64M

Author:
Problem type

Max returns home from a successful Halloween harvest. Tired and procrasting on homework, he dumps his N candies onto the table before going to finish his ICS homework.

Max's sister, May, who stayed home all night, decides to take advantage of her brother's harvest and share them with her K friends. She sees the candy on the table and begins putting them in separate bags (halloween-themed of course), one for each friend. However, May wants each of her friends to receive identical bags. What is the maximum number of candies each friend can receive?

Note that not all of the candies must be distributed into the bags.

Constraints

1 \le N, K \le 10^6

Input Specification

The first line will contain N and K, the number of candies Max collects and the number of friends May has.

The next line will contain a string of N lowercase characters, the candies that Max got from his harvest. Each distinct letter represents a unique candy.

Output Specification

Output a single number, the maximum number of candies each of May's friends can receive.

Sample Input 1

14 2
happyhalloween

Sample Output 1

5

Sample Explanation 1

Each of the two bags can contain the candies [a, e, h, l, p].

Sample Input 2

44 3
spookyscaryskeletonssendshiversdownyourspine

Sample Output 2

7

Comments

There are no comments at the moment.