
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 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 is the number of cards with that
letter written on them, squared. For example, if she has
cards with the letterk
, she gets points. - For each word
krokod
she can make from her cards, she gets an extra points.

d
k
o
r
krokod
can be spelled Paula also has
Help her determine the maximum score she can get with her cards.
Input Specification
The first line contains integers
The second line contains a sequence of d
, k
, o
and r
.
Output Specification
In the first and only line, output Paula's maximum possible score.
Constraints
Subtask | Points | Constraints |
---|---|---|
1 | 17 | |
2 | 26 | |
3 | 7 | No additional constraints. |
Sample Input 1
15 0
krokodkrokodkrk
Sample Output 1
79
Explanation for Sample 1
Look at the illustration in the task statement.
Sample Input 2
5 1
rokod
Sample Output 2
17
Explanation for Sample 2
For the maximum possible score, Paula can replace her crocodile card with a green card having the letter k
.
Sample Input 3
8 2
ddkkoorr
Sample Output 3
35
Comments