#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=(ll)1E12;//10^12
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
const double EPS=1E-8;
////////////////////////////////////////

bool match(string s,int k){
    int n=s.size();
    if(k>=n-2||n<=2)return false;
    if(s[k]=='A'&&s[k+1]=='B'&&s[k+2]=='C')return true;
    else return false;
}

bool dfs(string s){
    if(s=="ABC")return true;
    int n=s.size();
    if(n<=3)return false;
    
    vector<int>v;
    int c[3];memset(c,0,sizeof(c));
    rep(i,0,n-1){
        if(match(s,i)){
            v.pb(i);
            i+=2;
        }else{
            c[s[i]-'A']++;
        }
    }
    if(v.size()==0)return false;
    rep(i,0,2){
        if(c[i]==0){
            string t;
            int pos=0;
            rep(j,0,n-1){
                if(pos<=v.size()-1&&v[pos]==j){
                    t+=('A'+i);
                    j+=2;
                    pos++;
                }else{
                    t+=s[j];
                }
            }
            if(dfs(t))return true;
        }
    }
    return false;
}


int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    
    string s;cin>>s;
    if(dfs(s))cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
    return 0;
}
