This page is still under construction.

Parts of this page are still being built. What you see may change.

ABC Gene

Time limit2sMemory limit512 MB

Summary
Starting from "ABC", repeatedly replace every occurrence of one chosen letter with "ABC"; decide whether a given string can be produced.
Level

Medium7 of 10

Topics
String, Greedy, Divide and conquer, Recursion
Solved
No attempts yet

Problem

There is a gene sequence represented by the string ABC. You may perform the following operation any number of times to rewrite this gene sequence.

  • Choose one of the characters A, B, and C. Call it xx. Simultaneously replace every xx contained in the gene sequence with ABC.

You are given a string SS consisting only of A, B, and C. Determine whether the gene sequence can be made to match SS.

Input

The input is given from standard input in the following format.

SS

Output

If the gene sequence can be made to match SS, print Yes; otherwise, print No on a single line.

Constraints

  • 1≤∣S∣≤5,0001\leq|S|\leq5,000
  • SS consists only of A, B, and C.

Examples3

  1. Example 1

    Input
    ABC
    
    Expected output
    Yes
    
  2. Example 2

    Input
    AABCC
    
    Expected output
    Yes
    
  3. Example 3

    Input
    AABCABC
    
    Expected output
    No