#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define REP(i,n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<29
#define LINF LLONG_MAX/3
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(v) (v).begin(),(v).end()
#define all(v) ALL(v)
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }

constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

#define yes puts("Yes")
#define no puts("No")

void solve(string s){

    while(s.size()>3){
        bool f = false;
        for(int i=0;i<s.size();i++){
            if(s.substr(i,3)=="ABC"){
                f=true;
                break;
            }
        }
        if(!f) break;
        string tmp="";
        string c;
        if(s.substr(0,3)=="ABC"){
            c = "A";
        }else if(s.substr(s.size()-3,3)=="ABC"){
            c = "C";
        }else{
            f = true;
            for(int i=1;i<s.size()-1;i++){
                if(s[i]=='B'){
                    if(!(s[i-1]=='A' and s[i+1]=='C')){
                        no;
                        return;
                    }
                }
            }
            c = "B";
        }

        for(int i=0;i<s.size();i++) if(s.substr(i,3)=="ABC"){
            s.replace(i,3,c);
        }
    }

    if(s=="ABC") yes;
    else no;
}

int main(){
    while(1){
        string s;
        cin>>s;
        if(s=="0") break;
        //cout << s << " -> ";
        solve(s);

        break;
    }
}
### Prompt

Please create a solution in Cpp to the following problem:

ABC Gene

There is a gene sequence represented by the string `ABC`. You can rewrite this gene sequence by performing the following operations several times.

* Choose one of the letters `A`,` B`, `C`. Let this be x. Replace all x in the gene sequence with `ABC` at the same time.



Given a string S consisting only of `A`,` B`, and `C`. Determine if the gene sequence can be matched to S.

Constraints

* 1 ≤ | S | ≤ 5,000
* S consists only of `A`,` B`, and `C`.



Input Format

Input is given from standard input in the following format.


S


Output Format

Output `Yes` if the gene sequence can be matched to S, and` No` if it cannot be matched.

Sample Input 1


ABC


Sample Output 1


Yes


The gene sequence is `ABC` from the beginning.

Sample Input 2


AABCC


Sample Output 2


Yes


If you select `B` and perform the operation, it becomes` ABC` → `AABCC`.

Sample Input 3


AABCABC


Sample Output 3


No


For example, even if you select `C` and perform an operation, it does not change from` AABCC` to `AABCABC`. Since all `C`s are replaced with` ABC` at the same time, the actual result is `AABCC` →` AABABCABC`.





Example

Input

ABC


Output

Yes

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define REP(i,n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<29
#define LINF LLONG_MAX/3
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(v) (v).begin(),(v).end()
#define all(v) ALL(v)
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }

constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

#define yes puts("Yes")
#define no puts("No")

void solve(string s){

    while(s.size()>3){
        bool f = false;
        for(int i=0;i<s.size();i++){
            if(s.substr(i,3)=="ABC"){
                f=true;
                break;
            }
        }
        if(!f) break;
        string tmp="";
        string c;
        if(s.substr(0,3)=="ABC"){
            c = "A";
        }else if(s.substr(s.size()-3,3)=="ABC"){
            c = "C";
        }else{
            f = true;
            for(int i=1;i<s.size()-1;i++){
                if(s[i]=='B'){
                    if(!(s[i-1]=='A' and s[i+1]=='C')){
                        no;
                        return;
                    }
                }
            }
            c = "B";
        }

        for(int i=0;i<s.size();i++) if(s.substr(i,3)=="ABC"){
            s.replace(i,3,c);
        }
    }

    if(s=="ABC") yes;
    else no;
}

int main(){
    while(1){
        string s;
        cin>>s;
        if(s=="0") break;
        //cout << s << " -> ";
        solve(s);

        break;
    }
}
```