LearnPy Hub
← Arena
IntermediateRating 1400

Tasks With Cooldown

Each task (a capital letter) takes 1 unit of time. Two copies of the same task must have at least c units between them; the CPU may stay idle. Print the least total time to finish all tasks.

Input

The task letters on one line, then c.

Output

One integer.

Sample 1

Input
AAABBB
2
Output
8

Sample 2

Input
AAABBB
0
Output
6
solution.py
Output appears here
Tasks With Cooldown · Python Arena problem · LearnPy Hub