#C6682. Final String Length

    ID: 50469 Type: Default 1000ms 256MiB

Final String Length

Final String Length

Given a binary string containing only the characters '0' and '1', you are allowed to perform the following operation any number of times:

Select any pair of adjacent characters where one is '0' and the other is '1' (i.e. they are different) and remove both characters from the string. Repeat this operation until no more removals are possible.

Formally, if (s) is the input binary string and (f(s)) is the final string after performing all possible operations, then you need to output (|f(s)|), the length of the final string.

For example, given the binary string "1100", one possible sequence of operations will remove all characters, resulting in a final length of (0).

inputFormat

A single line containing a non-empty binary string composed exclusively of '0' and '1'.

outputFormat

Output a single integer representing the length of the final string after all possible removal operations have been performed.## sample

1100
0