#K88357. Light Removal Game

    ID: 37290 Type: Default 1000ms 256MiB

Light Removal Game

Light Removal Game

You are given a column of lights represented by a string s where each character represents a color (for example, 'R' for red, 'G' for green, 'B' for blue, etc.). You can perform the following operation any number of times:

  • Select three consecutive lights with the same color and remove them.

After removal, the remaining parts of the column are concatenated together. Determine whether it is possible to repeatedly apply this operation so that the column becomes completely empty.

Example 1: For the input "RGBRGB", no sequence of operations can remove all lights, so the answer is 0.

Example 2: For the input "RRRGGGBBB", you can remove "RRR" then "GGG" then "BBB" to clear the column, so the answer is 1.

Note: An empty column (empty string) is considered already empty.

inputFormat

The input is a single line containing a string s, representing the column of lights. The string may be empty.

outputFormat

Output a single integer: 1 if it is possible to remove the lights such that the column becomes empty, otherwise 0.

## sample
RGBRGB
0