LogiQuest

124. Count Binary Substrings

EasyCounting

Count the non-empty substrings that have the same number of 0s and 1s, with all 0s grouped together and all 1s grouped together (like 0011 or 10).

Input format

A single binary string.

Output format

The count.

Example 1

Input

00110011

Output

6

Example 2

Input

10101

Output

4

Constraints

1 ≤ |s| ≤ 10⁵

Read input from standard input and print the answer to standard output. Your code is judged against 4 test cases, most of them hidden.

Loading the MyLoginn IDE…