#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#define ll long long
using namespace std;
template <class T>
inline void rd(T &x) {
	x=0; char c=getchar(); int f=1;
	while(!isdigit(c)) { if(c=='-') f=-1; c=getchar(); }
	while(isdigit(c)) x=x*10-'0'+c,c=getchar(); x*=f;
}
const int N=1e6+10;
int S[N],mp[3],buc[3];
int n;
void change(int a,int b) {
	swap(mp[a],mp[b]);
	for(int i=1;i<=n;++i) {
		if(S[i]==a) S[i]=b;
		else if(S[i]==b) S[i]=a;
	}
}
int L[N],R[N];
void del(int x) {
	buc[S[x]]--;
	R[L[x]]=R[x];
	L[R[x]]=L[x];
}


int main() {
	mp[1]=1,mp[2]=2;
	
	{
		static char str[N];
		scanf("%s",str+1);
		int m=strlen(str+1);
		for(int i=1;i<=m;++i)
			if(i==1||str[i]!=str[i-1]) S[++n]=str[i]-'A';
	}
	
	S[0]=-1,S[n+1]=-2;
	for(int i=1;i<=n;++i) L[i]=i-1,R[i]=i+1; R[0]=1,L[n+1]=n;
	
	buc[0]=buc[1]=buc[2]=0;
	for(int i=1;i<=n;++i) buc[S[i]]++;
	
	{
		int ch=0;
		if(buc[1]<=min(buc[2],buc[0])) ch=1;
		if(buc[2]<=min(buc[1],buc[0])) ch=2;
		if(ch) change(0,ch),swap(buc[0],buc[ch]);
		if(buc[1]<buc[2]) change(1,2),swap(buc[1],buc[2]);
	}
	
	{
		int t=buc[1]-buc[2];
		for(int i=R[0];i<=n&&t;i=R[i])
			if(S[i]==1&&S[L[i]]!=S[R[i]]) del(i),t--;

		for(int i=R[0];i<=n&&t;i=R[i]) 
			if(S[i]==1&&S[L[i]]==0&&S[R[i]]==0) del(R[i]),del(i),t--;

	}
	{
		int t=buc[2]-buc[0];
		for(int i=R[0];R[i]<=n&&t;i=R[i])
			if(S[i]!=0&&S[R[i]]!=0&&S[L[i]]!=S[R[R[i]]])
				del(R[i]),del(i),t--;
	}
	for(int i=R[0];i<=n;i=R[i]) putchar('A'+mp[S[i]]);
	return 0;
}