Party#2154

Party

1 second
64 megabytes
Easy

Kate is preparing for a party and has bought a very unusual garland for it. The garland is a closed chain of bulbs, where each bulb can be in one of the following states: N — does not glow, R — glows red, G — glows green, B — glows blue. Every second, the state of each bulb changes according to the following table:

where the row is chosen by the current state of the bulb, and the column is chosen by the state of the bulb on its right. The value at the intersection of the chosen row and column gives the new state of the bulb. For example, if a bulb glows red (R) and the bulb on the right glows green (G), then the bulb will glow blue (B) in the next second. If a bulb and its right neighbour both glow blue, then the bulb will not glow at all in the next second. All bulbs change their states simultaneously. Such behaviour should (theoretically) lead to constant twinkling of the garland. Unfortunately, sometimes the garland can end up in a state where all bulbs do not glow, and thus the garland stops twinkling. Kate is worried that this might spoil the party. She can set the initial state of each bulb as she wishes. Help her determine for how long the garland will twinkle starting from a given initial state.

Input

The input file contains a single string consisting of characters 'N', 'R', 'G', and 'B', which describes the initial state of the garland. Each character determines the initial state of a bulb. The bulbs are listed from left to right. The first bulb is to the right of the last one. The length of the string does not exceed characters.

Output

Output the number of seconds during which the garland will twinkle. If the garland does not stop twinkling (at least until the power is turned off), print "Party!" (quotes for clarity).

The garland changes its state according to the following table:

RGBG BRRB GNGN GGGG NNNN

Examples

Example 1

Loading
Loading