#K39937. Final String Length after Consecutive Removal

    ID: 26531 Type: Default 1000ms 256MiB

Final String Length after Consecutive Removal

Final String Length after Consecutive Removal

Given a string \(s\), perform the following operation repeatedly:

If two adjacent characters in the string are the same, remove both of them from the string. This operation is repeated as long as there is at least one pair of adjacent duplicate characters.

Your task is to compute the length of the final string after no further operations can be applied.

For example, given the string "abbaca", after performing the operations the final string becomes "ca", whose length is 2.

inputFormat

The input consists of a single line containing a non-empty string \(s\) composed of lowercase English letters.

Constraints:

  • \(1 \leq |s| \leq 10^5\)

outputFormat

Output a single integer representing the length of the final string after performing consecutive duplicate removals as many times as possible.

## sample
abbaca
2