#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;

#define BIG_NUM 2000000000

using namespace std;

int main(){

	char buf[5001],work[5001],pre,to_change;
	scanf("%s",buf);

	int length,limit,index,pre_length;
	bool FLG = true,A_FLG,B_FLG,C_FLG;

	for(length = 0; buf[length] != '\0'; length++);

	do{
		if(length <= 3)break;
		pre_length = length;

		limit = length-3;
		index = 0;
		pre = 'D';
		to_change = 'D';
		A_FLG = B_FLG = C_FLG = false;
		for(int i = 0; i < length;){
			if(i <= limit && buf[i] == 'A' && buf[i+1] == 'B' && buf[i+2] == 'C'){
				if(to_change == 'D'){ //?????????????????§???????????????????????????????????????????????????????????????!!
					switch(pre){
					case 'D':
						if(!A_FLG){ //???????????§????????????A??????????????????????????????
							work[index++] = 'A';
							to_change = 'A';
						}else{
							FLG = false;
						}
						break;
					case 'A':
						if(!B_FLG){ //???????????§????????????B??????????????????????????????
							work[index++] = 'B';
							to_change = 'B';
						}else{
							FLG = false;
						}
						break;
					case 'B':
						if(!C_FLG){ //???????????§????????????C??????????????????????????????
							work[index++] = 'C';
							to_change = 'C';
						}else{
							FLG = false;
						}
						break;
					case 'C':
						FLG = false;
						break;
					}
				}else{
					work[index++] = to_change;
				}
				if(!FLG)break;

				i+=3;
			}else{
				if(buf[i] == to_change){ //???????????????????????????????????????????????§?????¨??????????????????????????????
					FLG = false;
					break;
				}else{
					work[index++] = buf[i];
					switch(buf[i]){
					case 'A':
						A_FLG = true;
						break;
					case 'B':
						B_FLG = true;
						break;
					case 'C':
						C_FLG = true;
						break;
					}

					pre = buf[i];
					i++;
				}
			}
		}
		if(!FLG){
			length = 0;
			break;
		}

		work[index] = '\0';
		length = index;

		for(int i = 0; i <= length; i++){
			buf[i] = work[i];
		}

		//if(length < 100)printf("%s\n",buf);

	}while(pre_length > length);

	if(length == 3 && buf[0] == 'A' && buf[1] == 'B' && buf[2] == 'C'){
		printf("Yes\n");
	}else{
		printf("No\n");
	}

	return 0;
}