#C4286. Minimum Deletions to Avoid Consecutive Repeating Characters

    ID: 47807 Type: Default 1000ms 256MiB

Minimum Deletions to Avoid Consecutive Repeating Characters

Minimum Deletions to Avoid Consecutive Repeating Characters

Given a string (s) consisting only of lowercase English letters, your task is to determine the minimum number of deletions required so that no two consecutive characters are the same.

More formally, for a string (s) of length (n), compute the number of deletions needed such that:

[ \text{Result} = \sum_{i=1}^{n-1} \mathbf{1}{{s_i = s{i+1}}}, ]

where (\mathbf{1}_{{condition}}) is 1 if the condition holds and 0 otherwise.

Ensure that you read the input from standard input and write the answer to standard output.

inputFormat

A single line containing the string (s).

outputFormat

Output a single integer representing the minimum number of deletions required to ensure that no two adjacent characters in (s) are identical.## sample

aabbcc
3