#include <bits/stdc++.h>
using namespace std;
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) GET_MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}


int main(){
  string s;
  cin>>s;

  while(s.size()>3){
    int i = 0;
    int n = s.size();
    string t;
    set<char> skip;
    while(i<n){
      while(i<n && s.substr(i,3) != "ABC"){
        skip.insert(s[i]);
        t.pb(s[i]);
        i++;
      }
      if(i<n){
        t.pb('X');
        i += 3;
      }
    }
    s.clear();
    if(skip.size()!=2){
      break;
    }
    char rp;
    rep(j,3) if(skip.count('A'+j)==0) rp = j+'A';
    for(char c : t){
      if(c=='X') s.pb(rp);
      else s.pb(c);
    }
  }

  if(s=="ABC") cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}