Time Limit: 8 sec / Memory Limit: 64 MB





Example

Input

eggchickenegg


Output

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

using namespace std;

int main(){
	string s;
	cin >> s;
	int cur = -1;
	int prev = s[0]=='e'?1:0;
	int next[] = {7, 3};
	int idx = 0;
	vector<vector<int> > v;
	while(idx < s.size()){
		int x = s[idx] == 'e';
		if(prev != x){
			v[cur].push_back(x);
		}else{
			v.push_back(vector<int>(1, x));
			cur++;
		}
		idx += next[x];
		prev = x;
	}

	reverse(v.begin(), v.end());
	int last = -1;
	bool rest = true;
	idx = 0;
	while(rest){
		rest = false;
		for(int i = 0; i < v.size(); i++){
			if(idx < v[i].size()){
				last = v[i][idx];
				rest = true;
			}
		}
		idx++;
	}

	cout << (last?"egg":"chicken") << endl;

	return 0;
}