Time Limit: 8 sec / Memory Limit: 64 MB





Example

Input

eggchickenegg


Output

egg
#include <iostream>
#include <string>
using namespace std;

int main() {
  string s;
  cin >> s;
  string ans;
  int egl = 3;
  int ckl = 7;
  bool prevEgg = s.find("egg") == 0;
  ans = prevEgg ? "egg" : "chicken";
  int generation = 1;
  int maxGen = 1;
  s = s.substr(prevEgg ? egl : ckl);
  while(s.size() > 0) {
    if (s.find("egg") == 0) {
      s = s.substr(egl);
      if (prevEgg) {
        generation = 1;
      }
      else {
        prevEgg = true;
        generation++;
        if (generation > maxGen) {
          maxGen = generation;
          ans = "egg";
        }
      }
    }
    else {
      s = s.substr(ckl);
      if (!prevEgg) {
        generation = 1;
      }
      else {
        prevEgg = false;
        generation++;
        if (generation > maxGen) {
          maxGen = generation;
          ans = "chicken";
        }
      }
    }
 }
  cout << ans << endl;
  return 0;
}