#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"

using namespace std;

const long long int MOD = 1000000007;
const long double EPS = 1e-8;

long long int N, M, K, H, W, L, R;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);

	string s;
	cin >> s;
	vector<int>a;
	vector<int>b;
	vector<int>c;
	while (s.size()>3) {
		map<char, int>m;
		for (auto i : s) {
			m[i]++;
		}
		a.push_back(m['A']);
		b.push_back(m['B']);
		c.push_back(m['C']);
		char nx = 'A';
		if (m[nx] > m['B'])nx = 'B';
		if (m[nx] > m['C'])nx = 'C';
		int l = -100;
		string t;
		for (int i = 0; i < s.size(); i++) {
			if (s[i] == 'A') {
				l = i;
				t.push_back('A');
			}
			if (s[i] == 'B') {
				if (l != i - 1) {
					l = -100;
				}
				t.push_back('B');
			}
			if (s[i] == 'C') {
				if (l == i - 2) {
					t.pop_back();
					t.pop_back();
					t.push_back(nx);
				}
				else {
					t.push_back('C');
				}
				l = -100;
			}
		}
		if (s == t)break;
		s = t;
	}
	N = a.size();
	bool ans = true;
	for (int i = N - 1; i > 0; i--) {
		bool box = false;
		if (a[i] + b[i] == b[i - 1] && a[i] + c[i] == c[i - 1])box |= true;
		if (b[i] + a[i] == a[i - 1] && b[i] + c[i] == c[i - 1])box |= true;
		if (c[i] + a[i] == a[i - 1] && c[i] + b[i] == b[i - 1])box |= true;
		ans &= box;
	}
	if (ans&&s=="ABC")cout << "Yes\n";
	else cout << "No\n";
	return 0;
}
