Novel
InterviewTime limit1sMemory limit1024 MB
Find the largest line width L so that no K identical lowercase letters appear consecutively within a single line of the string.
- Level
Medium4 of 10
- Topics
- String, Implementation, Math
- Solved
- No attempts yet
Problem
Today, September 24, is a very important day for Seohyeon, a boy who loves literature. It is the day the novel he spent years writing is released to the world!
Seohyeon's novel can be represented as a string of length . For convenience, consists only of lowercase English letters. No characters other than lowercase letters, including spaces or newline characters, appear in .
While reviewing the final draft, Seohyeon found a serious problem. If or more identical characters appear consecutively in one line, the readability drops badly!
To spare readers from discomfort, Seohyeon wants to choose a page width , an integer from 1 to , so that this case does not occur. A narrower page is harder to read, so he wants to be the largest possible value.
When the width is set to , the first characters of are shown on the first line, the next characters on the next line, and so on, with characters per line. Only the last line may show fewer than characters.
SNUPC ends at the same time Seohyeon's novel is published, so he must revise the book quickly. Find the largest valid value of .
Input
The first line contains and , separated by a space. (; )
The second line contains the string of length , made of lowercase English letters.
Output
Print the maximum possible width.