Problems > How Many Blocks

How Many Blocks

Difficulty: 900 3000 ms 128 MB

strings

A block is a maximal run of equal characters. Count the blocks of the binary string.

Input: one line with a binary string.

Output: the number of blocks.

Constraints:

  • 1 ≤ |S| ≤ 105

Sample Tests

Input 1
0011011
Output 1
4
Input 2
1111
Output 2
1

Read the Editorial

Discussion (opens after you solve — no spoilers before)

No comments yet.

Submit Your Solution

Log in or create a free account to run and submit code.