7Krokods
문제
When he is not making videos for his YouTube channel, the famous programmer influencer Krokod likes to play boardgames with his friend Paula. He wants to play the game 7Krokods, but Paula doesn’t like complex games, so Krokod decided that they will play only with green and crocodile cards.
Paula has green cards, and each of them has one of the following letters written on it: d, k, o, or r. Her total score is defined as the sum of the following components:
- For each letter, she gets as much points as is the number of cards with that letter written on them, squared. For example, if she has cards with the letter
k, she gets points. - For each word
krokodshe can make from her cards, she gets an extra points.
Illustration of the first example.
Paula has letters d (2 · 2 = 4 points), letters k (6 · 6 = 36 points), letters o (4 · 4 = 16 points) and letters r (3 · 3 = 9 points). The word krokod can be spelled times (7 · 2 = 14 points). Her total score is . ()
Paula also has crocodile cards. She can replace each of the crocodile cards with a green card having a letter of her choice. She will do it in a way that maximizes her score.
Help her determine the maximum score she can get with her cards.
입력
The first line contains integers and (0 ≤ n ≤ 100, 0 ≤ m ≤ 10), the number of green cards and the number of crocodile’s cards.
The second line contains a sequence of characters, where the -th characters represents the letter on the i-th green card. The sequence consists only of characters d, k, o and r.
출력
In the first and only line output Paula’s maximum possible score.
힌트
Clarification of the first example: Look at the illustation in the task statement.
Clarification of the second example: For the maximum possible score, Paula can replace her crocodile card with a green card having the letter k.
예제
예제 1
15 0 krokodkrokodkrk
79
예제 2
5 1 rokod
17
예제 3
8 2 ddkkoorr
35