#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (n); i++)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    const string ABC = "ABC";
    string s;
    cin >> s;
    while (1) {
        if (s == ABC) {
            cout << "Yes" << endl;
            return 0;
        }
        vector<int> cnt(3);
        int n = s.size();
        REP(i, n) { cnt[s[i] - 'A']++; }
        int mi = min({cnt[0], cnt[1], cnt[2]});
        int id = -1;
        REP(c, 3) {
            if (cnt[c] == mi) {
                if (id != -1) {
                    cout << "No" << endl;
                    return 0;
                }
                id = c;
            }
        }
        string t;
        REP(i, n) {
            if (i < n - 2 && s.substr(i, 3) == ABC) {
                t.push_back('A' + id);
                i += 2;
            } else {
                t.push_back(s[i]);
            }
        }
        if (s.size() == t.size()) {
            cout << "No" << endl;
            return 0;
        }
        s = move(t);
    }
}

