#include <bits/stdc++.h>
#define meow(args...) fprintf(stderr, args)
template<class T1, class T2> inline bool cmin(T1 &a, const T2 &b) {return b<a?(a=b, true):false;}
template<class T1, class T2> inline bool cmax(T1 &a, const T2 &b) {return a<b?(a=b, true):false;}
template<class Type> Type read() {
	Type a;
	bool b;
	unsigned char c;
	while(c=getchar()-48, (c>9)&(c!=253));
	for(a=(b=c==253)?0:c; (c=getchar()-48)<=9; a=a*10+c);
	return b?-a:a;
}
int (*rd)()=read<int>;
typedef unsigned u32;
typedef long long s64;
typedef unsigned long long u64;

const int N=1e6+5;
int n, prev[N], next[N], cnt[3];
char s[N];
int main() {
	int rev[3], rem=0;
	std::pair<int, char> hub[3]={{0, 0}, {0, 1}, {0, 2}};
	assert(scanf("%s", s)==1);
	n=std::unique(s, s+strlen(s))-s;
	for(int i=0; i<n; ++i) ++hub[s[i]-'A'].first;
	std::sort(hub, hub+3);
	for(int i=0; i<3; ++i) cnt[i]=hub[i].first, rev[hub[i].second]=i;
	for(int i=0; i<n; ++i) s[i]=rev[s[i]-'A'];
	for(int i=0, j=0; i<=n; ++i) {
		if(i==n||s[i]==0) {
			if(j<0) --rem;
			if(j>0&&i!=n&&i!=1) ++rem;
			j=0;
		} else if(s[i]==1) j=-1;
		else j|=1;
	}
	if(rem>0) {
		for(int i=2; i<n&&rem; ++i)
			if(s[i-2]==0&&s[i-1]==2&&s[i]==0) {
				s[i-2]=s[i-1]=-1;
				--rem, --cnt[0], --cnt[2];
			}
		n=std::remove(s, s+n, -1)-s;
	}
	rem=cnt[2]-cnt[1];
	for(int i=1; i<=n&&rem; ++i)
		if((i==1||i==n||s[i-2]+s[i]==1)&&s[i-1]==2) {
			s[i-1]=-1;
			--rem, --cnt[2];
		}
	n=std::remove(s, s+n, -1)-s;
	rem=cnt[1]-cnt[0];
	for(int i=1, j=0; i<n&&j<rem; ++i)
		if(s[i-1]+s[i]==3&&(i==2*j+1||i+1==n||s[i+1]==s[i-1])) {
			s[i-1]=s[i]=-1;
			--cnt[1], --cnt[2];
			++j;
		}
	n=std::remove(s, s+n, -1)-s;
	for(int i=0; i<n; ++i) s[i]=hub[s[i]].second+'A';
	s[n]=0;
	puts(s);
	return 0;
}
