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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(a) (a).begin(),(a).end()

int main(){
  string s;
  cin>>s;
  while (s.size() > 3) {
    vector<int> found(3, false);
    vector<bool> abc(s.size(), false);
    REP(i, s.size()-2) {
      if (s.substr(i, 3) != "ABC") {
        if (!abc[i]) {
          found[s[i] - 'A'] = 1;
        }
      } else {
        abc[i] = abc[i+1] = abc[i+2] = true;
      }
    }
    if (!abc[s.size()-2]) {
      found[s[s.size()-2] - 'A'] = 1;
    } if (!abc.back()) {
      found[s[s.size()-1] - 'A'] = 1;
    }
    if (found[0] + found[1] + found[2] != 2) break;
    char c = 'A';
    if (found[0] && found[1]) c = 'C';
    if (found[1] && found[2]) c = 'A';
    if (found[2] && found[0]) c = 'B';
    string next;
    REP(i, s.size()) {
      if (abc[i]) {
        if (s[i] == 'A') {
          next += c;
        }
      } else {
        next += s[i];
      }
    }
    s = next;
  }
  if (s == "ABC") {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}