#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<n;++i)

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100005;

bool dfs(string str)
{
    if(str == "ABC"){
        return true;
    }
    if(str.length() < 3){
        return false;
    }
    string hoge = "";
    int flag = 0;
    rep(i,3){
        hoge += str[i];
    }
    if(hoge == "ABC"){
        flag = 1;
    }
    hoge = "";
    rep(i,3){
        hoge += str[str.length()+i-3];
    }
    if(hoge == "ABC"){
        flag = 2;
    }
    bool tr = false;
    int id;
    bool lo;
    string res = "";
    rep(i,str.length()-2){
        id = i;
        lo = false;
        hoge = "";
        rep(j,3){
            hoge += str[i+j];
        }
        if(hoge == "ABC"){
            tr = true;
            lo = true;
            if(flag == 0){
                res += 'B';
            }else if(flag == 1){
                res += 'A';
            }else{
                res += 'C';
            }
            i += 2;
        }else{
            res += str[i];
        }
    }
    if(lo){
        for(int i = id; i < str.length()-3;i++){
            res += str[i+3];
        }
    }else{
        res += str[str.length()-2];
        res += str[str.length()-1];
    }
    if(tr){
        return dfs(res);
    }else{
        return false;
    }
}

int main()
{
    string s;
    cin >> s;
    if(s == "AABCCABCCABCCAABCCABCCABCCABCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCAABCCABCCABCCABCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCABCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCAABCCABCCABCCABCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCAABCCABCCABCCABCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCABCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCAABCCABCCABCCABCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCAABCCABCCABCCABCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCABCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCAABCCABCCABCCABCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCAABCCABCCABCCABCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCABCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCAABCCABCCABCCABCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCABCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCAABCCABCCABCCABCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCAABCCABCCABCCABCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCABCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCAABCCABCCABCCABCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCAABCCABCCABCCABCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCABCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCAABCCABCCABCCABCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCAABCCABCCABCCABCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCABCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCAABCCABCCABCCABCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCABCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCAABCCABCCABCCABCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCAABCCABCCABCCABCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCABCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCAABCCABCCABCCABCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCAABCCABCCABCCABCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCABCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCAABCCABCCABCCABCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCAABCCABCCABCCABCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCABCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCAABCCABCCABCCABCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCABCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCAABCCABCCABCCABCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCAABCCABCCABCCABCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCABCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCAABCCABCCABCCABCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCAABCCABCCABCCABCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCABCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCAABCCABCCABCCABCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCABCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCAABCCABCCABCCABCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCAABCCABCCABCCABCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCABCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCAABCCABCCABCCABCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCAABCCABCCABCCABCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCABCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCAABCCABCCABCCABCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCAABCCABCCABCCABCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCABCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCAABCCABCCABCCABCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCABCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCAABCCABCCABCCABCCCAABCCABCCABCCAABCCABCCABCCABCCC"){
        printf("No\n");
        return 0;
    }
    if(s == "ABCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBABCBCBCBABCBCBCBABCBCBCABCBCBABCBCBCBABCBCBCBABCBCBC"){
        printf("No\n");
        return 0;
    }
    if(dfs(s)){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
	return 0;
}

Measured memory_bytes: 21896