Simple Problem - 2

3.8

4 votes
Easy, Very Easy
Problem

Bella has a line of N tiles indexed from 0 to n-1. She wants to paint them to match a color configuration C, which is comprised of two colours RED (R) and BLUE (B) .

In one stroke, Bella can paint 1 or more adjacent tiles a single color. After she finishes painting, each tile i should be painted color Ci.

It should be noted that it is not allowed to apply more than 1 stroke on a tile.

Given the required color configuration, find and print the minimum number of strokes required for Bella to paint all N tiles.

Note: In a line of tiles, 2 tiles with the indices i and j are considered adjacent only if |j - i| = 1.

Input

The first line contains a single integer N, denoting the number of tiles to be painted. The second line contains a string C, denoting the desired color configuration.

Constraints

  • 1 ≤N ≤ 1000
  • Every character in string C is either R(RED) or B(BLUE).

Output

Print the minimum number of strokes required to paint all N tiles in the desired color configuration.

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

Bella will need 3 strokes to paint all 5 tiles.

Editor Image

?