eolymp
bolt
Try our new interface for solving problems
Problems

Pancakes

Pancakes

Boy Pete decided to prepare her mother a birthday present - a festive breakfast. He decided to make a delicious tea and bake pancakes. Unfortunately, not distinguished by outstanding culinary skills, Peter was unable to keep up with pancakes. Each of them has turned out burnt on one side and underdone on the other. As a result, \textbf{N} Petit turned black and white pancakes. All the pancakes he put on a large plate on each other. Now Peter wants to turn them so that they were light-up - Peter thinks that because they liked my mother. To flip the pancakes he had a shovel, which he may take a few top pancakes (from one to the whole stack) and turn them all together (so that the top pancake will be in place from the bottom made ​​of pancakes). For the minimum number of such actions Pete could turn all the pancakes light side up? \InputFile The first line of the input file is given a number \textbf{N} (\textbf{1} ≤ \textbf{N} ≤ \textbf{100000}) - the number of pancakes. Next \textbf{N} lines are described in the pancakes, top to bottom. If the \textbf{i}-th row is the symbol \textbf{W}, then the \textbf{i}-th pancake is underdone side up, and if \textbf{B}, then the burnt side up. \OutputFile The output file output a single number - the number of rolling over, which should make Peter to put all the pancakes underdone side up.
Time limit 1 second
Memory limit 64 MiB
Input example #1
6
W
B
B
B
W
B
Output example #1
4
Author Tatiana Krivosheeva