#include <bits/stdc++.h>   using namespace std;   void pri(deque<int> arr) {     for (int i : arr) cout << i <<    ;     cout << endl;   }   int main() {     string s;     cin >> s;     int n = s.size();     if (n <= 3) {       cout << s[0] << endl;       return 0;     }     deque<int> a1;     deque<int> b1;     deque<int> c1;     int as[n + 2];     int bs[n + 2];     int cs[n + 2];     memset(as, 0, sizeof as);     memset(bs, 0, sizeof bs);     memset(cs, 0, sizeof cs);     as[0] = 0;     bs[0] = 0;     cs[0] = 0;     for (int i = 0; i < n; i++) {       if (s[i] ==  a ) {         a1.push_back(i);         as[i + 1]++;       } else if (s[i] ==  b ) {         b1.push_back(i);         bs[i + 1]++;       } else {         c1.push_back(i);         cs[i + 1]++;       }       as[i + 1] += as[i];       bs[i + 1] += bs[i];       cs[i + 1] += cs[i];     }     int lim = -10;     int mx = 1000006;     string ans =   ;     while (true) {       int a = lim;       int b = lim;       int c = lim;       if (a1.size() > 1) {         a = a1[a1.size() - 1] - a1[0];       }       if (b1.size() > 1) {         b = b1[b1.size() - 1] - b1[0];       }       if (c1.size() > 1) {         c = c1.back() - c1.front();       }       int x = max(max(a, b), c);       if (x == lim) break;       int az = mx, bz = mx, cz = mx;       if (a1.size() > 0) {         az = as[a1[a1.size() - 1] + 1] - as[a1[0]];       }       if (b1.size() > 0) {         bz = bs[b1[b1.size() - 1] + 1] - bs[b1[0]];       }       if (c1.size() > 0) {         cz = cs[c1[c1.size() - 1] + 1] - cs[c1[0]];       }       if (x > a) {         a = lim;         az = mx;       }       if (x > b) {         b = lim;         bz = mx;       }       if (x > c) {         c = lim;         cz = mx;       }       x += min(min(az, bz), cz);       a += az;       b += bz;       c += cz;       if (x == a) {         ans +=  a ;         while (b1.size() > 0 && b1[0] < a1[0]) b1.pop_front();         while (b1.size() > 0 && b1[b1.size() - 1] > a1[a1.size() - 1])           b1.pop_back();         while (c1.size() > 0 && c1[0] < a1[0]) c1.pop_front();         while (c1.size() > 0 && c1[c1.size() - 1] > a1[a1.size() - 1])           c1.pop_back();         a1.pop_front();         a1.pop_back();       } else if (x == b) {         ans +=  b ;         while (a1.size() > 0 && a1[0] < b1[0]) a1.pop_front();         while (a1.size() > 0 && a1[a1.size() - 1] > b1[b1.size() - 1])           a1.pop_back();         while (c1.size() > 0 && c1[0] < b1[0]) c1.pop_front();         while (c1.size() > 0 && c1[c1.size() - 1] > b1[b1.size() - 1])           c1.pop_back();         b1.pop_front();         b1.pop_back();       } else {         ans +=  c ;         while (b1.size() > 0 && b1[0] < c1[0]) b1.pop_front();         while (b1.size() > 0 && b1[b1.size() - 1] > c1[c1.size() - 1])           b1.pop_back();         while (a1.size() > 0 && a1[0] < c1[0]) a1.pop_front();         while (a1.size() > 0 && a1[a1.size() - 1] > c1[c1.size() - 1])           a1.pop_back();         c1.pop_front();         c1.pop_back();       }     }     string aux = ans;     reverse(aux.begin(), aux.end());     if (c1.size() > 0) {       ans +=  c ;     } else {       if (b1.size() > 0) {         ans +=  b ;       } else {         if (a1.size()) {           ans +=  a ;         }       }     }     ans += aux;     if (ans.size() >= (int)n / 2)       cout << ans;     else       cout <<  IMPOSSIBLE ;     return 0;   }