#K2306. Minimum Subarrays to Group Identical Fruits

    ID: 24707 Type: Default 1000ms 256MiB

Minimum Subarrays to Group Identical Fruits

Minimum Subarrays to Group Identical Fruits

Given a string s consisting of lowercase English letters where each character represents a type of fruit, determine the minimum number of contiguous subarrays required such that in each subarray, all the fruits are identical.

More formally, if you are given a string \( s \), split it into the minimum number of contiguous segments so that for every segment, all characters are the same. For example, if \( s = \texttt{aaabbbccc} \), then the result is 3: "aaa", "bbb", "ccc".

If the string is empty, the answer is 0.

inputFormat

The input consists of a single line containing a non-negative string s of lowercase English letters. The string represents the sequence of fruits.

outputFormat

Output a single integer representing the minimum number of contiguous subarrays needed such that in each subarray, all characters are the same.

## sample
aaabbbccc
3