Linear Pachinko

Time limit1sMemory limit128 MB

Problem

This problem is inspired by Pachinko, a game popular in Japan. A traditional Pachinko machine is a cross between a vertical pinball machine and a slot machine. The player launches small steel balls to the top of the machine with a plunger, as in pinball. A ball drops through a maze of pins that deflect it, and eventually either exits through a hole at the bottom and is lost, or lands in one of many gates scattered across the machine, which reward the player with more balls. Players who collect enough balls can trade them for prizes.

For this problem, a linear Pachinko machine is a string made of one or more of the following characters:

  • a hole .
  • a floor tile _
  • a wall |
  • a mountain /\ (the two characters / and \ together form one mountain)

No wall or mountain is ever adjacent to another wall or mountain.

To play, a ball is dropped straight down onto one character of the machine. What happens next depends on that character:

  • Dropped onto a hole ., the ball falls through.
  • Dropped onto a floor tile _, the ball stops immediately.
  • Dropped onto the left side of a mountain /, the ball rolls to the left across any number of consecutive floor tiles until it falls into a hole, falls off the left end of the machine, or stops by hitting a wall or a mountain.
  • Dropped onto the right side of a mountain \, the ball behaves the same way but rolls to the right.
  • Dropped onto a wall |, the ball behaves as if it had been dropped onto the left or the right side of a mountain, each with 50% probability.

A ball is dropped at random onto the machine, with every character position equally likely. What is the probability that the ball falls through a hole or off an end of the machine?

For example, consider this machine (the digits above only mark character positions and are not part of the machine):

123456789
/\.|__/\.

The probability that a ball escapes (through a hole or off an end), position by position, is: 1 = 100%, 2 = 100%, 3 = 100%, 4 = 50%, 5 = 0%, 6 = 0%, 7 = 0%, 8 = 100%, 9 = 100%. The probability for the whole machine is the average of these, about 61.111%.

Input

The input consists of one or more linear Pachinko machines. Each machine is 1 to 79 characters long and appears on its own line. A final line containing only # marks the end of the input.

Output

For each machine, compute as accurately as possible the probability that a randomly dropped ball falls through a hole or off an end, expressed as a percentage. Print this percentage on its own line, truncated to an integer by dropping any fractional part (for example, 61.111% is printed as 61).