#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>
#include <iostream>
#include <algorithm>
#include <fstream>
#include <bitset>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>

using namespace std;

const int MAXN = 1000005;

int n,m,cnt[3];
int l[MAXN];
int r[MAXN];

char s[MAXN];

void rmv(int p)
{
	l[r[p]] = l[p];
	r[l[p]] = r[p];
}

void go1(int c,int t)
{
	for (int i = r[0];i <= n && t;i = r[i])
		if (s[i] == 'A' + c && s[l[i]] != s[r[i]])
		{
			rmv(i);
			cnt[c]--;
			t--;
		}
}

void go2(int b,int c,int t)
{
	for (int i = r[0];r[i] <= n && t;i = r[i])
		if (min(s[i],s[r[i]]) == 'A' + min(b,c) && max(s[i],s[r[i]]) == 'A' + max(b,c) && s[l[i]] != s[r[r[i]]])
		{
			rmv(i);
			rmv(r[i]);
			i = r[i];
			t--;
			cnt[b]--;
			cnt[c]--;
		}
}

int main()
{
	scanf("%s",s + 1);
	n = strlen(s + 1);
	s[0] = 'D';
	for (int i = 1;i <= n;i++)
		if (s[i] != s[i - 1])
			cnt[(s[++m] = s[i]) - 'A']++;
	n = m;
	s[n + 1] = 'E';
	int a = 0,b = 1,c = 2;
	if (cnt[a] > cnt[b])
		swap(a,b);
	if (cnt[a] > cnt[c])
		swap(a,c);
	if (cnt[b] > cnt[c])
		swap(b,c);
	for (int i = 0;i <= n + 1;i++)
	{
		l[i] = i - 1;
		r[i] = i + 1;
	}
	go1(c,cnt[c] - cnt[b]);
	go2(a,c,cnt[c] - cnt[b]);
	go2(b,c,cnt[b] - cnt[a]);
	for (int i = r[0];i <= n;i = r[i])
		putchar(s[i]);
	putchar('\n');
	return 0;
}