#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXLEN=1000000;
struct Block { char first; int len; bool canempty; Block() {} Block(char first,int len,bool canempty):first(first),len(len),canempty(canempty) {} };

int slen;
char s[MAXLEN+1];
char ans[MAXLEN+1];

int freq[3];
pair<int,char> o[3];

vector<Block> blocks;

vector<int> constrained[3];
vector<int> unconstrained;
vector<int> outer;

void solve() {
	{ int nlen=0; REP(i,slen) if(i==0||s[i]!=s[nlen-1]) s[nlen++]=s[i]; s[nlen]='\0'; slen=nlen; }
	REP(i,3) freq[i]=0; REP(i,slen) ++freq[s[i]-'A'];
	REP(i,3) o[i]=MP(freq[i],'A'+i); sort(o,o+3);
	int x=o[0].second-'A',y=o[1].second-'A',z=o[2].second-'A'; int nx=o[0].first,ny=o[1].first,nz=o[2].first;
	if(nx==0) { ans[0]='\0'; return; }
	//printf("s=%s\n",s);
	blocks.clear();
	for(int l=0,r=l;l<slen;l=r) {
		if(s[l]=='A'+x) while(r<slen&&s[r]=='A'+x) ++r; else while(r<slen&&s[r]!='A'+x) ++r;
		if(s[l]!='A'+x) blocks.PB(Block(s[l],r-l,l==0||r==slen));
	}
	REP(i,3) constrained[i].clear(); unconstrained.clear(); outer.clear();
	REPSZ(i,blocks) if(blocks[i].len%2==0) unconstrained.PB(i); else if(blocks[i].len>=3||blocks[i].canempty) constrained[blocks[i].first-'A'].PB(i);
	while(nz>ny&&SZ(constrained[z])>=1) { int idx=constrained[z].back(); constrained[z].pop_back(); blocks[idx].len--; nz--; if(blocks[idx].len>=2) unconstrained.PB(idx); }
	while(nz>ny&&SZ(unconstrained)>=1) { int idx=unconstrained.back(); unconstrained.pop_back(); blocks[idx].len--; nz--; blocks[idx].first='A'+y; if(blocks[idx].len>=3||blocks[idx].canempty) constrained[y].PB(idx); }
	if(nz>ny) {
		vector<int> opt; FORSZ(i,1,blocks) if(blocks[i].len==1&&blocks[i].first=='A'+z&&blocks[i-1].len==1&&blocks[i-1].first=='A'+z) opt.PB(i);
		//printf("opt:"); REPSZ(i,opt) printf(" %d",opt[i]); puts("");
		while(nz>ny&&SZ(opt)>=1) { int idx=opt.back(); opt.pop_back(); blocks[idx].len--; nz--; nx--; }
	}
	assert(nz==ny);
	while(ny>nx&&SZ(unconstrained)>=2) {
		int idx1=unconstrained.back(); unconstrained.pop_back(); blocks[idx1].len--; ny--; blocks[idx1].first='A'+z; if(blocks[idx1].len>=3||blocks[idx1].canempty) constrained[z].PB(idx1);
		int idx2=unconstrained.back(); unconstrained.pop_back(); blocks[idx2].len--; nz--; blocks[idx2].first='A'+y; if(blocks[idx2].len>=3||blocks[idx2].canempty) constrained[y].PB(idx2);
	}
	REP(i,3) while(ny>nx&&SZ(constrained[i])>=1) { int idx=constrained[i].back(); constrained[i].pop_back(); if(blocks[idx].len==1) { outer.PB(idx); continue; } blocks[idx].len-=2; ny-=1,nz-=1; if(blocks[idx].len>=3||blocks[idx].canempty) constrained[i].PB(idx); }
	while(ny>nx&&SZ(unconstrained)==1) { int idx=unconstrained.back(); unconstrained.pop_back(); if(blocks[idx].len>=4||blocks[idx].canempty) { blocks[idx].len-=2; ny--,nz--; } if(blocks[idx].len>=2) unconstrained.PB(idx); if(blocks[idx].len==0||blocks[idx].len==2&&!blocks[idx].canempty) break; }
	assert(nx==ny&&ny==nz);
	//printf("x=%c nx=%d y=%c ny=%d z=%c nz=%d\n",'A'+x,nx,'A'+y,ny,'A'+z,nz);
	//printf("blocks:"); REPSZ(i,blocks) printf(" %c%d%c",blocks[i].first,blocks[i].len,blocks[i].canempty?'E':'.'); puts("");
	int nans=0;
	REPSZ(i,blocks) {
		if(blocks[i].len>=1&&(i>=1||i==0&&!blocks[i].canempty)) ans[nans++]='A'+x;
		REP(j,blocks[i].len) ans[nans++]=j%2==0?blocks[i].first:'A'+y+z-(blocks[i].first-'A');
	}
	if(!blocks.back().canempty||blocks.back().len==0) ans[nans++]='A'+x;
	ans[nans]='\0';
}

void run() {
	scanf("%s",s); slen=strlen(s);
	solve();
	printf("%s\n",ans);
}

int main() {
	run();
	return 0;
}


Measured memory_bytes: 12268