// Copyright 2019 zhouzhendong. All Rights Reserved.
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof x)
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
#define outval(x) cerr<<#x" = "<<x<<endl
#define outtag(x) cerr<<"-----------------"#x"-----------------\n"
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
                    For(_x,L,R) cerr<<a[_x]<<" ";cerr<<endl;
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair <int,int> pii;
LL read(){
    LL x=0,f=0;
    char ch=getchar();
    while (!isdigit(ch))
        f=ch=='-',ch=getchar();
    while (isdigit(ch))
        x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
    return f?-x:x;
}
const int N=1000005*2;
int n;
char s[N];
int a[N];
int pre[N],nxt[N];
int del[N];
int cnt[3];
void erase(int x){
	pre[nxt[x]]=pre[x];
	nxt[pre[x]]=nxt[x];
	del[x]=1;
	cnt[a[x]]--;
}
struct Node{
	int x,y,z;
	Node(){}
	Node(int _x,int _y,int _z){
		x=_x,y=_y,z=_z;
	}
};
queue <Node> q0[3],q1[3][3];
void Ins(int i){
	if (i==0||i==n+1)
		return;
	int x=pre[i],y=i,z=nxt[i];
	if (x==0||z==n+1||a[x]!=a[z])
		q0[a[y]].push(Node(x,y,z));
	else
		q1[a[y]][a[x]].push(Node(x,y,z));
}
int main(){
	cin>>(s+1);
	n=unique(s+1,s+1+strlen(s+1))-s-1;
	nxt[0]=1,pre[n+1]=n;
	a[n+1]=-1;
	For(i,1,n)
		nxt[i]=i+1,pre[i]=i-1;
	For(i,1,n)
		cnt[a[i]=s[i]-'A']++;
	for (int i=nxt[0];i!=n+1;i=nxt[i])
		Ins(i);
	while (1){
		int id[3]={0,1,2};
		sort(id,id+3,[&](int a,int b){return cnt[a]>cnt[b];});
		int c0=id[0],c1=id[1];
		if (cnt[0]==cnt[1]&&cnt[0]==cnt[2])
			break;
		if (!q0[c0].empty()){
			Node now=q0[c0].front();
			q0[c0].pop();
			if (del[now.x]||del[now.y]||del[now.z])
				continue;
			erase(now.y);
			Ins(now.x);
			Ins(now.z);
		}
		else {
			assert(!q1[c0][c1].empty());
			Node now=q1[c0][c1].front();
			q1[c0][c1].pop();
			if (del[now.x]||del[now.y]||del[now.z])
				continue;
			int w=pre[now.x];
			erase(now.x);
			erase(now.y);
			Ins(w);
			Ins(now.z);
		}
	}
    int cnt = 0;
	for (int i=nxt[0];i!=n+1;i=nxt[i])
		putchar('A'+a[i]);
	puts("");
	return 0;
}