#C7079. Minimum Hand Switches in Musical Notes

    ID: 50910 Type: Default 1000ms 256MiB

Minimum Hand Switches in Musical Notes

Minimum Hand Switches in Musical Notes

You are given a sequence of musical notes represented as a string of capital letters from 'A' to 'G'. When playing the sequence, you start with your left hand. Every time the current note is different from the previous note, you switch hands. More formally, if we denote the sequence as \(S = s_1 s_2 \ldots s_n\), you start with the left hand at \(s_1\) and for every \(i\) from 2 to \(n\), if \(s_i \neq s_{i-1}\), you perform a hand switch. Your task is to compute the minimum number of hand switches necessary to play the entire sequence.

Note: The hand switching operation is performed regardless of the specific note values; it only happens when the consecutive notes differ.

inputFormat

The input consists of a single line containing a non-empty string notes that represents the sequence of musical notes. Each character is one of the capital letters 'A' to 'G'.

For example:

AABBC

outputFormat

Output a single integer denoting the minimum number of hand switches required to play the entire sequence.

For the example above, the output should be:

2
## sample
AABBC
2