#K63737. Circular RGB Sequence

    ID: 31820 Type: Default 1000ms 256MiB

Circular RGB Sequence

Circular RGB Sequence

You are given a string representing beads arranged in a circle. Each bead is colored R, G, or B. Your task is to determine if by reading the beads in order (with circular wrapping) there exists any contiguous subsequence that exactly matches the pattern \(RGB\).

Note that the pattern must appear exactly as "RGB". Because the beads are in a circular arrangement, the pattern may wrap from the end of the string back to the beginning.

For example, the sequence "RGBRGBR" contains the pattern because if you consider the circular arrangement, the substring starting at the last bead and continuing from the beginning forms "RGB".

inputFormat

The input is given via standard input (stdin) as a single line containing a string of characters. Each character is one of R, G, or B representing the color of a bead. The beads are arranged in a circle.

Input Format:

A single line containing the beads string.

outputFormat

Output via standard output (stdout) a single line containing YES if the beads can form an \(RGB\) sequence continuously, otherwise output NO.

Output Format:

YES or NO
## sample
RGBRGB
YES