Олимпиадный тренинг

Задача 38552. hike


A group of schoolchildren decided to go camping along the Moscow River. The Moskva River has many tributaries that can flow into it both from the right and from the left bank.

The students want to start the hike at some point on the left bank and end the hike at some point on the right bank, possibly crossing the rivers several times. As you know, crossing both a river and a tributary is a certain difficulty, so they want to minimize the number of crossings made.

The schoolchildren studied the map in advance and wrote down the sequence in which tributaries flow into the Moscow River along their entire route.

Based on the given description of the tributaries, help the students determine the minimum number of crossings they will have to make during the trip.

Input
The only line contains a description of the Moskva River between the start and end points of the hike. The string length does not exceed 105 characters.

Each character of the string can be one of three Latin letters L, R or B. The letter L means that the next tributary flows into the river from the left bank, R - the tributary flows into the river from the right bank and B - the tributaries flow from both banks of the river in one place. The hike starts on the left bank before the described part of the river and ends on the right bank after the described part.

Imprint
Print one integer - the minimum number of crossings.

Notes
Drawing for the example below.
Examples
# Input Output
1 LLBLRRBRRL 5