#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <functional>
#include <climits>
#include <string>
#include <map>
#include <iomanip>

bool is_valid(const std::vector<char>& str, const int pos) {
	return (pos >= 0 && pos + 2 < str.size()) && str[pos] == 'A' && str[pos + 1] == 'B' && str[pos + 2] == 'C';
}
bool can_make(const std::string& str) {
	std::vector<std::vector<char>> temp(2);
	for (const auto c : str) temp[0].push_back(c);
	for (auto i = 0; temp[i % 2].size() > 3; ++i) {
		bool a = true, b = true, c = true;
		bool exists_a = false, exists_b = false, exists_c = false;
		for (auto j = 0; j < temp[i % 2].size(); ++j) {
			switch (temp[i % 2][j]) {
			case 'A':
				exists_a = true;
				a &= is_valid(temp[i % 2], j); break;
			case 'B':
				exists_b = true;
				b &= is_valid(temp[i % 2], j - 1); break;
			case 'C':
				exists_c = true;
				c &= is_valid(temp[i % 2], j - 2); break;
			default: break;
			}
		}
		if (!exists_a || !exists_b || !exists_c) return false;
		auto count = 0;
		if (a) ++count; if (b) ++count; if (c) ++count;
		if (count != 1) return false;
		for (auto j = 0; j < temp[i % 2].size(); ++j) {
			switch (temp[i % 2][j]) {
			case 'A': 
				if (a) {
					for (auto k = 0; k < 3; ++k)
						temp[i % 2][j + k] = 'X';
					temp[i % 2][j] = 'A';
				}
				break;
			case 'B':
				if (b) {
					for (auto k = 0; k < 3; ++k)
						temp[i % 2][j + k - 1] = 'X';
					temp[i % 2][j - 1] = 'B';
				}
				break;
			case 'C':
				if (c) {
					for (auto k = 0; k < 3; ++k)
						temp[i % 2][j + k - 2] = 'X';
					temp[i % 2][j - 2] = 'C';
				}
				break;
			default: break;
			}
		}
		temp[(i + 1) % 2].clear();
		for (auto j = 0; j < temp[i % 2].size(); ++j) {
			if (temp[i % 2][j] != 'X') temp[(i + 1) % 2].push_back(temp[i % 2][j]);
		}
	}
	return is_valid(temp[0], 0) || is_valid(temp[1], 0);
}
int main() {
	std::string str; std::cin >> str;
	if (can_make(str)) {
		std::cout << "Yes\n";
	}
	else {
		std::cout << "No\n";
	}
}
