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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

bool check;

void rec(string s) {
    if (s == "ABC") {
        check = true;
        return;
    }
    Int n = s.size();
    string t = "";
    map<char, int> mp;
    bool update = false;
    for (int i = 0; i < n; i++) {
        if (i + 2 < (Int)s.size() and s.substr(i, 3) == "ABC") {
            update = true;
            i += 2;
            t += "T";
        } else {
            t += s[i];
            mp[s[i]]++;
        }
    }
    if (not update or mp.size() != 2) return;
    char c = 'A';
    if (mp['B'] == 0) c = 'B';
    if (mp['C'] == 0) c = 'C';
    for (Int i = 0; i < (Int)t.size(); i++) {
        if (t[i] == 'T') {
            t[i] = c;
        }
    }
    rec(t);
}

int main() {
    string s;
    cin >> s;
    check = false;
    rec(s);
    dump(check ? "Yes" : "No");
    return 0;
}

