import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0; 
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //

void solve(){
	char[] s = readln.chomp.to!(char[]);
	int n = s.length.to!int;
	
	char[] s2;
	char cold = 'x';
	foreach(c; s){
		if(cold != c) s2 ~= c;
		cold = c;
	}
	log("s2:", s2);
	
	int a, b, c;
	foreach(char ch; s2){
		log("ch:", ch);
		if(ch == 'A') a += 1;
		else if(ch == 'B') b += 1;
		else c += 1;
	}
	log("a:", a, "b:", b, "c:", c);
	
	if(a <= b && a <= c){
		log("a.");
		if(b > c) s2 = perform2(b - c, s2, "ABC", "AC", "CBA", "CA");
		else s2 = perform2(c - b, s2, "ACB", "AB", "BCA", "BA");
		log("s2:", s2);
		int d = min(b, c);
		s2 = perform2(d - a, s2, "CBC", "C", "BCB", "B");
		log("s2:", s2);
	}
	else if(b <= c && b <= a){
		log("b.");
		if(c > a) s2 = perform2(c - a, s2, "BCA", "BA", "ABC", "AB");
		else s2 = perform2(a - c, s2, "BAC", "BC", "CAB", "CB");
		log("s2:", s2);
		int d = min(c, a);
		s2 = perform2(d - b, s2, "ACA", "A", "CAC", "C");
		log("s2:", s2);
	}
	else if(c <= a && c <= b){
		log("c.");
		if(a > b) s2 = perform2(a - b, s2, "CAB", "CB", "BAC", "BC");
		else s2 = perform2(b - a, s2, "CBA", "CA", "ABC", "AC");
		log("s2:", s2);
		int d = min(a, b);
		s2 = perform2(d - c, s2, "BAB", "B", "ABA", "A");
		log("s2:", s2);
	}
	
	s2.writeln;
}

char[] perform(int cnt, char[] s, string x, string y){
	char[] res;
	for(int i = 0; i < s.length; ){
		if(i < s.length - x.length + 1 && s[i] == x[0] && s[i + 1] == x[1] && s[i + 2] == x[2]){
			res ~= y;
			i += x.length;
			cnt -= 1;
			if(cnt == 0) break;
		}
		else{
			res ~= s[i];
			i += 1;
		}
	}
	return res;
}

char[] perform2(int cnt, char[] s, string x1, string y1, string x2, string y2){
	char[] res;
	for(int i = 0; i < s.length; ){
		if(cnt > 0){
			if(i < s.length - x1.length + 1 && s[i] == x1[0] && s[i + 1] == x1[1] && s[i + 2] == x1[2]){
				res ~= y1;
				i += x1.length;
				cnt -= 1;
				continue;
			}
			else if(i < s.length - x2.length + 1 && s[i] == x2[0] && s[i + 1] == x2[1] && s[i + 2] == x2[2]){
				res ~= y2;
				i += x2.length;
				cnt -= 1;
				continue;
			}
		}
		
		res ~= s[i];
		i += 1;
	}
	return res;
}
