/* This example solution assumes that you have dumped all different types of
 * sentences contained in inputs and did sort of analysis on them. It will show
 * that almost any sentence contains some a specific word which can be used to
 * uniquely identify it. Then, only remaining thing is to do proper
 * calculations. 
 */


#include <string>
#include <vector>
#include <iostream>
#include <cctype>
#include <climits>

using namespace std;

int cnt = 0;
int min_cnt = 0;
int orig_cnt = -1;
int terminal_left = 0;

int get_number (string s) {
	int i;

	for (i = 0; i < s.size(); i++) {
		if (isdigit (s[i]))
			return atoi (&s.c_str()[i]);
	};

	cerr << "eeeek, cout not parse: " << s << endl;
	return INT_MAX;
};

pair<int, int> get_numbers (string s) {
	int i = 0;
	pair<int,int> ret;

	for (i = 0; i < s.size(); i++) {
		if (isdigit (s[i])) {
			ret.first = atoi (&s.c_str()[i]) ;
			break;
		};
	};

	while (isdigit (s[i])) i++;


	for (; i < s.size(); i++) {
		if (isdigit (s[i])) {
			ret.second = atoi (&s.c_str()[i]);
			return ret;
		};
	};
	cerr << "eeeek, cout not parse: " << s << endl;
	return pair<int,int>(INT_MAX, INT_MAX);
};

void eval_sentence (string s) {
	pair<int,int> n;
	/* recognize sentences */
	if (s.find ("Once upon the time") != -1) {
		orig_cnt = 0;
		return;
	};

	/* sentences from easy input */
	if (s.find ("After that") != -1 || s.find ("however") != -1 || 
			s.find ("watching a cat") != -1 || s.find ("voluntarily") != -1 ||
			s.find ("silently") != -1) {
		n = get_numbers(s);
		cnt += n.first;
		cnt -= n.second;
		if (cnt < min_cnt) min_cnt = cnt;
		return;
	};

	if (s.find ("summarized") != -1) {
		/* things are getting a bit complicated here, we have to distinguish
		 * between two cases, which are quite similar.
		 */
		n = get_numbers (s);
		if (s.find ("in") < s.find ("out")) {
			cnt += n.first;
			cnt -= n.second;
			if (cnt < min_cnt) min_cnt = cnt;
		} else {
			cnt -= n.first;
			if (cnt < min_cnt) min_cnt = cnt;
			cnt += n.second;
		};

		return;
	};

	/* hard in */
	if (s.find ("suddenly") != -1 || s.find ("waiting") != -1 || 
			s.find ("lungs") != -1 || s.find ("eager") != -1) {
		cnt += get_number (s);
		return;
	};

	/* hard out */
	if (s.find ("as they could") != -1 || s.find ("emptied") != -1 ||
		s.find ("got out") != -1) {
		cnt -= get_number (s);
		if (cnt < min_cnt) min_cnt = cnt;
		return;
	};

	/* hard reversed :) */
	if (s.find ("Immediately") != -1 || s.find ("occassion") != -1) {
		n = get_numbers (s);
		cnt -= n.first;
		if (cnt <min_cnt) min_cnt = cnt;
		cnt += n.second;
		return;
	};

	if (s.find ("terminal") != -1) {
		cnt-=get_number (s);
		if (cnt < min_cnt) min_cnt = cnt;
	};

	/* if we reached this point, we are probably dealing with sentence not
	 * containing any numbers */
	return;
};

void print_and_clear () {
	if (orig_cnt != -1) {
		/* we have exact number of travellers at start*/
		if (orig_cnt == cnt && min_cnt >=0)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	} else {
		/* the initial number of travellers is missing */
		/* there had to be at least -min_cnt people at the start, though */
		if (cnt - min_cnt <= 0)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	};


	cnt = 0;
	min_cnt = 0;
	orig_cnt = -1;
};

int main (void) {
	string word;
	string sentence;

	while (cin.good ()) {
		cin >> word;
		sentence += word + " ";

		if (word.find('.') != -1) {
			eval_sentence (sentence);
			sentence = "";
		};
		if (sentence.find("NEW STORY") != -1) {
			print_and_clear ();
			sentence = "";
		};
	};

	print_and_clear ();
	return 0;
};
