#include <bits/stdc++.h>

using namespace std;

#define rep(i,n) for(int i=0; i<n; i++)

map<string,bool> used;

bool ok = false;

bool dfs(string s){
	if(used[s]) return false;
	used[s] = true;
	if(s.size()==1) return true;
	vector<int> p;
	string t;
	int pos = 0;
	vector<int> cnt(3);
	while(pos<s.size()){
		if(s.substr(pos,3)=="ABC"){
			p.push_back(t.size());
			t+='C';
			pos += 3;
		}
		else{
			cnt[s[pos]-'A']++;
			t += s[pos];
			pos++;
		}
	}
	if(cnt[2]==0&&dfs(t)) return true;
	rep(i,2){
		for(int x: p){
			t[x] = char('A'+i);
		}
		if(cnt[i]==0&&dfs(t)) return true;
	}
	return false;
}

int main(){
	string s;
	cin>>s;
	if(s.size()<3) cout<<"No"<<endl;
	else cout<<(dfs(s)?"Yes":"No")<<endl;
}