cswork / OAOpen practice workspace

YahooOA #2

Count Binary Substrings

Estimated EasyJudge-ready

Topics (AI-labelled)StringsTwo Pointers

Count substrings consisting of two adjacent equal-length runs of consecutive 0s and 1s, counting each position separately.

See "Input" for the standard input/output conventions and constraints added by this site.

Input

A binary string of length 1..100000.

Output

Output the number of valid substrings.

Example 1

Input:

011001

Output:

4

Example 2

Input:

0011

Output:

2

Example 3

Input:

10101

Output:

4

Example 4

Input:

000111

Output:

3

Editorial

Loading solution…