406785: GYM102556 A A - Rank Riana and One Punch

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

A. A - Rank Riana and One Punchtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

Saitomo, an A-Rank professional hero who is famous as the One-Punch-Man, decided to share the real secret of his power to one of his disciples.

Riana (Saitomo's disciple) became a hero because she couldn't find any other job. Despite this sad fact, she is able to learn Saitomo's secret and can now also defeat any enemy with one punch. She is so strong that the shockwaves of her punch can be transmitted through the bodies of her enemies. This means that if an enemy is punched and defeated, the shockwaves of Riana's punch travels through the enemy to the enemy's neighbors and their neighbors' neighbors and so on and so forth. This domino effect only stops if there is an empty space between two enemies.

One day, a number of enemies appeared around the city, and formed a circle to surround it.

Given a string where X denotes that the space is occupied by an enemy, and . denotes that the space is empty, determine the minimum number of empty spaces that should be replaced with enemies so that Riana can defeat all enemies with at most one punch. The string is circular, which means that the last character of the string circles back and is connected to the first character.

Note that XXXXX means that the 5 enemies are beside each other, thus if you defeat any one of them, the shockwave will pass through and defeat all of them, but .X.X. will require Riana to use 2 punches to eliminate all enemies.

Input

The only input contains a string, consisting of either . or X

The length of the string will not exceed 100 characters.

Output

Output in a single line an integer denoting the minimum number of empty spaces needed to be filled with an enemy.

ExamplesInput
XX..XX.X....
Output
3
Input
X..XX.X..X
Output
3
Note

For the 2nd sample case, we can add 3 enemies (in locations 2, 3, 6) to connect all the enemies and transform it into XXXXXXX..X which Riana can use to defeat them all in one punch.

加入题单

上一题 下一题 算法标签: