#K41887. Minimum Removals for Consecutive Letters

    ID: 26965 Type: Default 1000ms 256MiB

Minimum Removals for Consecutive Letters

Minimum Removals for Consecutive Letters

You are given a string s. Your task is to determine the minimum number of characters that must be removed so that no character appears more than twice consecutively.

In other words, for any group of consecutive identical characters of length L (where L \(\geq 3\)), you need to remove \(L-2\) characters. For example, if a character appears 5 times in a row, you must remove 3 of them so that only 2 remain.

Input/Output Details: The input will be provided via stdin as a single line string. The output should be printed to stdout as a single integer representing the minimum number of removals required.

inputFormat

A single line containing the string s. The string may be empty or consist of lowercase letters.

outputFormat

A single integer that represents the minimum number of removals required so that no letter appears more than twice consecutively.## sample

aaabbbc
2