#K46127. Longest Consecutive 'X' Sequence

    ID: 27908 Type: Default 1000ms 256MiB

Longest Consecutive 'X' Sequence

Longest Consecutive 'X' Sequence

Given a string consisting of characters 'X' and 'O', you are required to determine the length of the longest contiguous sequence of 'X'.

The problem tests your ability to perform simple string traversal and count sequences.

Note: Input will be read from stdin and the result should be printed to stdout.

Mathematically, if we define a sequence as a contiguous block of 'X's in the string S, the answer is:

\(\max_{1 \leq i \leq n} \{ \text{length of contiguous block of } 'X' \text{ starting at position } i \}\)

inputFormat

The input consists of a single line containing a non-empty string of characters 'X' and 'O' only.

For example:

OXXXOXOXX

outputFormat

The output is a single integer representing the length of the longest consecutive sequence of 'X'.

For example:

3
## sample
OXXXOXOXX
3