#include<bits/stdc++.h>
using namespace std;
const int maxn=1e6+5;
inline int read(){
	char c=getchar();int t=0,f=1;
	while((!isdigit(c))&&(c!=EOF)){if(c=='-')f=-1;c=getchar();}
	while((isdigit(c))&&(c!=EOF)){t=(t<<3)+(t<<1)+(c^48);c=getchar();}
	return t*f;
}
char c[maxn],s[maxn];
int n,m,l[maxn],r[maxn],ton[3];
int mp[3];
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;
	}
	swap(ton[a],ton[b]);
}
inline void del(int i){
	r[l[i]]=r[i];
	l[r[i]]=l[i];
	ton[s[i]]--;
}
signed main(){
	mp[1]=1;mp[2]=2;
	scanf("%s",c+1);
	m=strlen(c+1);
	for(int i=1;i<=m;i++){
		if(c[i]!=c[i-1]){
			s[++n]=c[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;
	for(int i=1;i<=n;i++)ton[s[i]]++;
	int mn=0;
	if(ton[0]>ton[1])mn=1;
	if(ton[mn]>ton[2])mn=2;
	if(mn){
		change(0,mn);
	}
	if(ton[1]<ton[2]){
		change(1,2);
	}
	int t=ton[1]-ton[2];
	for(int i=1;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--;
		}
	}
	t=ton[2]-ton[0];
	for(int i=r[0];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;
}
