Under construction

Still being built. Things may change

7Krokods

Interview

Time limit1sMemory limit1024 MB

Summary
Assign each of m wildcard cards to the letters d, k, o, or r to maximize the sum of squared letter counts plus 7 points per krokod word formable.
Level

Easy3 of 10

Topics
Brute force, Implementation
Solved
No attempts yet

Problem

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 nn 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 many points as the number of cards with that letter, squared. For example, if she has 66 cards with the letter k, she gets 3636 points.
  • For each word krokod she can make from her cards, she gets an extra 77 points.

Illustration of the first example.

Paula has 22 letters d (2×2=42 \times 2 = 4 points), 66 letters k (6×6=366 \times 6 = 36 points), 44 letters o (4×4=164 \times 4 = 16 points) and 33 letters r (3×3=93 \times 3 = 9 points). The word krokod can be spelled 22 times (7×2=147 \times 2 = 14 points). Her total score is 7979. (4+36+16+9+14=794 + 36 + 16 + 9 + 14 = 79)

Paula also has mm 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.

Input

The first line contains integers nn and mm (0≤n≤1000 \le n \le 100, 0≤m≤100 \le m \le 10), the number of green cards and the number of crocodile's cards.

The second line contains a sequence of nn characters, where the ii-th characters represents the letter on the ii-th green card. The sequence consists only of characters d, k, o and r.

Output

In the first and only line output Paula's maximum possible score.

Hint

Clarification of the first example: Look at the illustration 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.

Examples3

  1. Example 1

    Input
    15 0
    krokodkrokodkrk
    
    Expected output
    79
    
  2. Example 2

    Input
    5 1
    rokod
    
    Expected output
    17
    
  3. Example 3

    Input
    8 2
    ddkkoorr
    
    Expected output
    35