#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int canbe(char s[]){
    int cnt=0,cur,cur2,len;
    char *sabc;
    int i;
    int ap,bp,cp;
    len = strlen(s);
    //printf("called:%s",s);
    //ABC?????????????´¢????????¨????????????????????§??????????????????
    ap = bp = cp = 1;
    for(i=0;i<len;i++){
        if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')cnt++;
        if(s[i]=='A'&&(s[i+1]!='B'||s[i+2]!='C'))ap = 0;
        if(s[i]=='B'&&(s[i-1]!='A'||s[i+1]!='C'))bp = 0;
        if(s[i]=='C'&&(s[i-2]!='A'||s[i-1]!='B'))cp = 0;
    }
    //printf("ap=%d bp=%d cp=%d\n",ap,bp,cp);
    sabc = (char *)calloc(len-2*cnt+5,sizeof(char));
    //??°???????????§?????????
    if(len==4&&cnt==1){
        //printf("%s");
        return 1;
    }else{
        if(cnt){
            //ABC???A?????????
            if(ap){
                cur = 0;
                for(i=0;i<len;i++){
                    if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C'){
                        sabc[cur] = 'A';
                        i+=2;
                    }else{
                        sabc[cur] = s[i];
                    }
                    cur++;
                }
                sabc[cur] = '\0';
                if(canbe(sabc)){
                    //printf("A\n");
                    return 1;
                }
            }
            //ABC???B?????????
            if(bp){
                cur = 0;
                for(i=0;i<len;i++){
                    if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C'){
                        sabc[cur] = 'B';
                        i+=2;
                    }else{
                        sabc[cur] = s[i];
                    }
                    cur++;
                }
                sabc[cur] = '\0';
                if(canbe(sabc)){
                    //printf("B\n");
                    return 1;
                }
            }
            //ABC???C?????????
            if(cp){
                cur = 0;
                for(i=0;i<len;i++){
                    if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C'){
                        sabc[cur] = 'C';
                        i+=2;
                    }else{
                        sabc[cur] = s[i];
                    }
                    cur++;
                }
                sabc[cur] = '\0';
                if(canbe(sabc)){
                    //printf("C\n");
                    return 1;
                }else{
                    return 0;
                }
            }
            return 0;
        }else{
            return 0;
        }
    }
}

int main(){
    char s[5005];
    fgets(s,5005,stdin);
    printf(canbe(s)? "Yes\n":"No\n");
}