Time Limit: 8 sec / Memory Limit: 64 MB





Example

Input

eggchickenegg


Output

egg
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

struct DATA{
  int size;
  int num;
  string str;
};

void Divide(const string, vector<string>*);
void Convert(const vector<string>, vector<DATA>*);
DATA MakeOneData(int, int, const string);
bool Compare(const DATA&, const DATA&);

int main(){
  string origin;
  vector<string> data1;
  vector<DATA> data2;

  cin >> origin;
  Divide(origin, &data1);
  Convert(data1, &data2);
  sort(data2.begin(), data2.end(), Compare);
  cout << data2[0].str << endl;

  return 0;
}

void Divide(const string str, vector<string>* data){
  int i=0;
  const string C("chicken");
  const string E("egg");

  while(i < str.size()){
    if(str[i] == C[0]){
      data->push_back(C);
      i += C.size();
    }else{
      data->push_back(E);
      i += E.size();
    }
  }
}

void Convert(const vector<string> data1, vector<DATA>* data2){
  int i, j, k;
  for(i=1, j=0, k=0; i<data1.size(); ++i){
    if(data1[i] == data1[i-1]){
      data2->push_back(MakeOneData(i-j, k, data1[i-1]));
      j=i;
      ++k;
    }
  }
  data2->push_back(MakeOneData(data1.size()-j, k, data1[data1.size()-1]));
}

DATA MakeOneData(int size, int num, const string str){
  DATA data;
  data.size = size;
  data.num = num;
  data.str = str;
  return data;
}

bool Compare(const DATA& x, const DATA& y){
  if(x.size == y.size) return (x.num < y.num);
  else return (x.size > y.size);
}