Ksonya and the Alphabet Circle
Ksonya is studying the English alphabet and defines a string as "alphabetical" if all its letters appear consecutively in the alphabet.
For example, the strings "abc", "xy", and "fg" are alphabetical, while "adef", "zxc", and "zab" are not.
Ksonya has a circle on which letters are written, and she wants to determine the length of the longest alphabetical string that can be found on this circle.
A string is considered part of the circle if all its characters are adjacent on the circle. In this circle, adjacent characters are at positions and , and , ..., and , and and . For instance, the string "abc" is part of the circle "bcda", but the string "bda" is not.
Giriş verilənləri
The first line contains a single integer (), representing the length of the circle.
The second line contains a single string of lowercase Latin letters of length , representing the circle of letters.
Çıxış verilənləri
Output a single number, which is the length of the longest alphabetical string that can be found on the circle.
Nümunələr
Qeyd
Explanation for the first test:
The string "abcd" fits (indices 4, 1, 2, 3 are adjacent) and is the longest.
Explanation for the second test:
Among all alphabetical strings of one letter, the string "a" is the smallest.
Explanation for the third test:
Among the alphabetical strings, the string "mnop" is the longest.
The entire English alphabet in one string is:
"abcdefghijklmnopqrstuvwxyz".
Qiymətləndirmə
points will be awarded to solutions that correctly handle the case where the longest alphabetical string is part of the input string itself, not the circle.