#include using namespace std; int main() { string word; bool begin = false; int count = 0; while(true) { cin >> word; if(cin.eof()) { break; } if(begin) { count++; } if(word == "beginning") { begin = true; } else if(word == "end") { if(!begin) { cout << "wrong sequence" << endl; return 0; } count--; begin = false; } } if(begin) { cout << "wrong sequence" << endl; return 0; } cout << count << endl; return 0; }