#K52317. Minimum Operations to Make a String Beautiful

    ID: 29283 Type: Default 1000ms 256MiB

Minimum Operations to Make a String Beautiful

Minimum Operations to Make a String Beautiful

In this problem, you are given a string of length (n) composed of lowercase English letters. A string is considered "beautiful" if no two adjacent characters are identical. In a single operation, you can replace any character with any other lowercase English letter. Your task is to determine the minimum number of operations required to convert the given string into a beautiful string.

Formally, let the string be represented as (s_0 s_1 \dots s_{n-1}). The string is beautiful if for every (i) ((1 \leq i < n)), (s_i \neq s_{i-1}). The minimum number of operations is given by [ \text{operations} = \sum_{i=1}^{n-1} \mathbb{1}(s_i = s_{i-1}), ] where (\mathbb{1}(\cdot)) is the indicator function.

inputFormat

The input is read from standard input (stdin) and consists of two lines:

  1. The first line contains an integer (n) (1 ≤ (n) ≤ 1000), the length of the string.
  2. The second line contains a string of length (n) consisting of lowercase English letters.

outputFormat

Print a single integer representing the minimum number of operations required to make the string beautiful, where the output is printed to standard output (stdout).## sample

5
aabbc
2