#C9560. Count Maximum Consecutive Characters

    ID: 53667 Type: Default 1000ms 256MiB

Count Maximum Consecutive Characters

Count Maximum Consecutive Characters

You are given a string s and a character c. Your task is to determine the maximum number of consecutive occurrences of the character c within the string s.

If the character does not appear, or if it never appears consecutively, output 0.

The problem can be formally stated as follows:

Given a string \(s\) and a character \(c\), find \(\max_{i \in [1,|s|]} L_i\) where \(L_i\) is the length of a contiguous segment of \(c\)s starting from position \(i\) in \(s\) (if \(s[i] \neq c\), then \(L_i=0\)).

inputFormat

The input is given via standard input (stdin) and consists of two lines:

  • The first line contains the string s.
  • The second line contains a single character c.

outputFormat

Output via standard output (stdout) a single integer representing the maximum number of consecutive occurrences of character c in string s.

## sample
aaabbbaaaccc
a
3