#include<bits/stdc++.h>
#define N 1000010
#define se second
#define fi first
using namespace std;
string s,ns;
pair<int,char> a[5];
int n,vi[N],s1,s2,s3;
int main(){
	cin>>s;n=s.length();ns="";for (int i=1;i<=n;i++)vi[i]=1;
	for (int i=1;i<n;i++)if (s[i]==s[i-1])vi[i]=0;
	for (int i=1;i<=n;i++)if (vi[i])ns+=s[i-1];
	s=ns;n=s.length();ns="";for (int i=1;i<=n;i++)vi[i]=1;
	for (int i=1;i<=n;i++)a[s[i-1]-'A'].fi++;
	for (int i=0;i<3;i++)a[i].se='A'+i;
	sort(a,a+3);
	for (int i=0;i<=n;){
		int ne=i+1;
		while (ne<=n&&s[ne-1]!=a[0].se)ne++;
		if (ne>i+1){
			if (ne==i+2){if (s[i]==a[1].se) s2++;else s3++;}else s1++;
		}
		i=ne;
	}
	if (s3>s1+s2){
		if (s[n-1]==a[2].se&&n>1&&s[n-2]==a[0].se){n--;a[2].fi--;s3--;}
		for (int i=0;i<=n&&s3>s1+s2;){
			int ne=i+1;
			while (ne<=n&&s[ne-1]!=a[0].se)ne++;
			if (ne==i+2&&s[i]==a[2].se){s3--;if (i)a[0].fi--;a[2].fi--;vi[i+1]=0;vi[i]=0;}
			i=ne;
		}
		if (a[1].fi>a[2].fi){swap(a[1],a[2]);swap(s2,s3);}
		for (int i=1;i<=n;i++)if (vi[i])ns+=s[i-1];
		s=ns;n=s.length();ns="";for (int i=1;i<=n;i++)vi[i]=1;
	}
	for (int i=0;i<=n&&a[2].fi>a[1].fi;){
		int ne=i+1;
		while (ne<=n&&s[ne-1]!=a[0].se)ne++;
		if (ne>i+2){if (s[i]==a[2].se){a[2].fi--;vi[i+1]=0;}if (s[ne-2]==a[2].se&&a[2].fi>a[1].fi){a[2].fi--;vi[ne-1]=0;}}
		i=ne;
	}
	for (int i=1;i<=n;i++)if (vi[i])ns+=s[i-1];
	s=ns;n=s.length();ns="";for (int i=1;i<=n;i++)vi[i]=1;
	for (int i=0;i<=n&&a[1].fi>a[0].fi;){
		int ne=i+1;
		while (ne<=n&&s[ne-1]!=a[0].se)ne++;
		while ((i+3<ne||(i+3==ne&&(i==0||ne==n+1)))&&a[1].fi>a[0].fi){vi[i+1]=0;vi[i+2]=0;i+=2;a[1].fi--;}
		i=ne;
	}
	for (int i=1;i<=n;i++)if (vi[i])ns+=s[i-1];
	cout<<ns<<endl;
	return 0;
}