#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;

bool solve() {
    string S;
    cin >> S;
    while(3 < S.size()) {
        ll cnt[3] = {};
        vector<ll> idx;
        for(ll i = 0; i < S.size(); i++) {
            if(!(i + 2 < S.size() && 
                 S[i] == 'A' &&
                 S[i + 1] == 'B' &&
                 S[i + 2] == 'C')) {
                cnt[S[i] - 'A']++;
            } else {
                idx.push_back(i);
                i += 2;
            }
        }
        char c = 0;
        if(!cnt[0] && cnt[1] && cnt[2]) c = 'A';
        if(cnt[0] && !cnt[1] && cnt[2]) c = 'B';
        if(cnt[0] && cnt[1] && !cnt[2]) c = 'C';
        if(c == 0) break;
        string T;
        ll idx_i = 0;
        for(ll i = 0; i < S.size(); i++) {
            if(idx_i < idx.size() && i == idx[idx_i]) {
                T += c;
                idx_i++;
                i += 2;
            } else {
                T += S[i];
            }
        }
        S = move(T);
    }
    return S == "ABC";
}

int main() {
    cout << (solve() ? "Yes" : "No") << endl;
    return 0;
}

