A - Altered States

Languages: C, C++, Java, Python, Kotlin
Time & Memory limits: (details)

Input

Output

Sample test(s)

Input
1 abacaba
--- Showing first 30 lines (click "Copy" to get full content) ---
Output
21
--- Showing first 30 lines (click "Copy" to get full content) ---
Input
2 abba bcab
--- Showing first 30 lines (click "Copy" to get full content) ---
Output
14
--- Showing first 30 lines (click "Copy" to get full content) ---
Input
5 abvsvdh ahusywbag inzuqwbd iajhhdt qweqweqwe
--- Showing first 30 lines (click "Copy" to get full content) ---
Output
142
--- Showing first 30 lines (click "Copy" to get full content) ---

Notes