import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		ArrayList<Character> c = new ArrayList<Character>();
		for (int i = 0; i < s.length(); i++) {
			c.add(s.charAt(i));
		}
		Collections.reverse(c);
		boolean f = true;
		int i = 0;
		while(f) {
			if ((c.get(i) == 'm') && (c.get(i+1) == 'a') && (c.get(i+2) == 'e') && (c.get(i+3) == 'r') && (c.get(i+4) == 'd')) {
				i += 5;
				if (i >= s.length()) break;
				continue;
			}
			if ((c.get(i) == 'e') && (c.get(i+1) == 's') && (c.get(i+2) == 'a') && (c.get(i+3) == 'r') && (c.get(i+4) == 'e')) {
				i += 5;
				if (i >= s.length()) break;
				continue;
			}
			if ((c.get(i) == 'r') && (c.get(i+1) == 'e') && (c.get(i+2) == 'm') && (c.get(i+3) == 'a') && (c.get(i+4) == 'e') && (c.get(i+5) == 'r') && (c.get(i+6) == 'd')) {
				i += 7;
				if (i >= s.length()) break;
				continue;
			}
			if ((c.get(i) == 'r') && (c.get(i+1) == 'e') && (c.get(i+2) == 's') && (c.get(i+3) == 'a') && (c.get(i+4) == 'r') && (c.get(i+5) == 'e')) {
				i += 6;
				if (i >= s.length()) break;
				continue;
			}
			f = false;
		}
		if (f) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
} import java.util.ArrayList; ArrayList java.util import java.util.Collections; Collections java.util import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		ArrayList<Character> c = new ArrayList<Character>();
		for (int i = 0; i < s.length(); i++) {
			c.add(s.charAt(i));
		}
		Collections.reverse(c);
		boolean f = true;
		int i = 0;
		while(f) {
			if ((c.get(i) == 'm') && (c.get(i+1) == 'a') && (c.get(i+2) == 'e') && (c.get(i+3) == 'r') && (c.get(i+4) == 'd')) {
				i += 5;
				if (i >= s.length()) break;
				continue;
			}
			if ((c.get(i) == 'e') && (c.get(i+1) == 's') && (c.get(i+2) == 'a') && (c.get(i+3) == 'r') && (c.get(i+4) == 'e')) {
				i += 5;
				if (i >= s.length()) break;
				continue;
			}
			if ((c.get(i) == 'r') && (c.get(i+1) == 'e') && (c.get(i+2) == 'm') && (c.get(i+3) == 'a') && (c.get(i+4) == 'e') && (c.get(i+5) == 'r') && (c.get(i+6) == 'd')) {
				i += 7;
				if (i >= s.length()) break;
				continue;
			}
			if ((c.get(i) == 'r') && (c.get(i+1) == 'e') && (c.get(i+2) == 's') && (c.get(i+3) == 'a') && (c.get(i+4) == 'r') && (c.get(i+5) == 'e')) {
				i += 6;
				if (i >= s.length()) break;
				continue;
			}
			f = false;
		}
		if (f) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
} Main public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		ArrayList<Character> c = new ArrayList<Character>();
		for (int i = 0; i < s.length(); i++) {
			c.add(s.charAt(i));
		}
		Collections.reverse(c);
		boolean f = true;
		int i = 0;
		while(f) {
			if ((c.get(i) == 'm') && (c.get(i+1) == 'a') && (c.get(i+2) == 'e') && (c.get(i+3) == 'r') && (c.get(i+4) == 'd')) {
				i += 5;
				if (i >= s.length()) break;
				continue;
			}
			if ((c.get(i) == 'e') && (c.get(i+1) == 's') && (c.get(i+2) == 'a') && (c.get(i+3) == 'r') && (c.get(i+4) == 'e')) {
				i += 5;
				if (i >= s.length()) break;
				continue;
			}
			if ((c.get(i) == 'r') && (c.get(i+1) == 'e') && (c.get(i+2) == 'm') && (c.get(i+3) == 'a') && (c.get(i+4) == 'e') && (c.get(i+5) == 'r') && (c.get(i+6) == 'd')) {
				i += 7;
				if (i >= s.length()) break;
				continue;
			}
			if ((c.get(i) == 'r') && (c.get(i+1) == 'e') && (c.get(i+2) == 's') && (c.get(i+3) == 'a') && (c.get(i+4) == 'r') && (c.get(i+5) == 'e')) {
				i += 6;
				if (i >= s.length()) break;
				continue;
			}
			f = false;
		}
		if (f) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	} main {
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		ArrayList<Character> c = new ArrayList<Character>();
		for (int i = 0; i < s.length(); i++) {
			c.add(s.charAt(i));
		}
		Collections.reverse(c);
		boolean f = true;
		int i = 0;
		while(f) {
			if ((c.get(i) == 'm') && (c.get(i+1) == 'a') && (c.get(i+2) == 'e') && (c.get(i+3) == 'r') && (c.get(i+4) == 'd')) {
				i += 5;
				if (i >= s.length()) break;
				continue;
			}
			if ((c.get(i) == 'e') && (c.get(i+1) == 's') && (c.get(i+2) == 'a') && (c.get(i+3) == 'r') && (c.get(i+4) == 'e')) {
				i += 5;
				if (i >= s.length()) break;
				continue;
			}
			if ((c.get(i) == 'r') && (c.get(i+1) == 'e') && (c.get(i+2) == 'm') && (c.get(i+3) == 'a') && (c.get(i+4) == 'e') && (c.get(i+5) == 'r') && (c.get(i+6) == 'd')) {
				i += 7;
				if (i >= s.length()) break;
				continue;
			}
			if ((c.get(i) == 'r') && (c.get(i+1) == 'e') && (c.get(i+2) == 's') && (c.get(i+3) == 'a') && (c.get(i+4) == 'r') && (c.get(i+5) == 'e')) {
				i += 6;
				if (i >= s.length()) break;
				continue;
			}
			f = false;
		}
		if (f) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) String s = scan.next(); s scan.next() scan.next scan ArrayList<Character> c = new ArrayList<Character>(); c new ArrayList<Character>() for (int i = 0; i < s.length(); i++) {
			c.add(s.charAt(i));
		} int i = 0; int i = 0; i 0 i < s.length() i s.length() s.length s i++ i++ i {
			c.add(s.charAt(i));
		} {
			c.add(s.charAt(i));
		} c.add(s.charAt(i)) c.add c s.charAt(i) s.charAt s i Collections.reverse(c) Collections.reverse Collections c boolean f = true; f true int i = 0; i 0 while(f) {
			if ((c.get(i) == 'm') && (c.get(i+1) == 'a') && (c.get(i+2) == 'e') && (c.get(i+3) == 'r') && (c.get(i+4) == 'd')) {
				i += 5;
				if (i >= s.length()) break;
				continue;
			}
			if ((c.get(i) == 'e') && (c.get(i+1) == 's') && (c.get(i+2) == 'a') && (c.get(i+3) == 'r') && (c.get(i+4) == 'e')) {
				i += 5;
				if (i >= s.length()) break;
				continue;
			}
			if ((c.get(i) == 'r') && (c.get(i+1) == 'e') && (c.get(i+2) == 'm') && (c.get(i+3) == 'a') && (c.get(i+4) == 'e') && (c.get(i+5) == 'r') && (c.get(i+6) == 'd')) {
				i += 7;
				if (i >= s.length()) break;
				continue;
			}
			if ((c.get(i) == 'r') && (c.get(i+1) == 'e') && (c.get(i+2) == 's') && (c.get(i+3) == 'a') && (c.get(i+4) == 'r') && (c.get(i+5) == 'e')) {
				i += 6;
				if (i >= s.length()) break;
				continue;
			}
			f = false;
		} f {
			if ((c.get(i) == 'm') && (c.get(i+1) == 'a') && (c.get(i+2) == 'e') && (c.get(i+3) == 'r') && (c.get(i+4) == 'd')) {
				i += 5;
				if (i >= s.length()) break;
				continue;
			}
			if ((c.get(i) == 'e') && (c.get(i+1) == 's') && (c.get(i+2) == 'a') && (c.get(i+3) == 'r') && (c.get(i+4) == 'e')) {
				i += 5;
				if (i >= s.length()) break;
				continue;
			}
			if ((c.get(i) == 'r') && (c.get(i+1) == 'e') && (c.get(i+2) == 'm') && (c.get(i+3) == 'a') && (c.get(i+4) == 'e') && (c.get(i+5) == 'r') && (c.get(i+6) == 'd')) {
				i += 7;
				if (i >= s.length()) break;
				continue;
			}
			if ((c.get(i) == 'r') && (c.get(i+1) == 'e') && (c.get(i+2) == 's') && (c.get(i+3) == 'a') && (c.get(i+4) == 'r') && (c.get(i+5) == 'e')) {
				i += 6;
				if (i >= s.length()) break;
				continue;
			}
			f = false;
		} if ((c.get(i) == 'm') && (c.get(i+1) == 'a') && (c.get(i+2) == 'e') && (c.get(i+3) == 'r') && (c.get(i+4) == 'd')) {
				i += 5;
				if (i >= s.length()) break;
				continue;
			} (c.get(i) == 'm') && (c.get(i+1) == 'a') && (c.get(i+2) == 'e') && (c.get(i+3) == 'r') && (c.get(i+4) == 'd') (c.get(i+3) == 'r') (c.get(i+2) == 'e') (c.get(i) == 'm') && (c.get(i+1) == 'a') && (c.get(i+2) == 'e') && (c.get(i+3) == 'r') && (c.get(i+4) == 'd') (c.get(i) == 'm') c.get(i) c.get c i 'm' (c.get(i+1) == 'a') c.get(i+1) c.get c i+1 i 1 'a' (c.get(i+2) == 'e') c.get(i+2) c.get c i+2 i 2 'e' (c.get(i+3) == 'r') c.get(i+3) c.get c i+3 i 3 'r' (c.get(i+4) == 'd') c.get(i+4) c.get c i+4 i 4 'd' {
				i += 5;
				if (i >= s.length()) break;
				continue;
			} i += 5 i 5 if (i >= s.length()) break; i >= s.length() i s.length() s.length s break; continue; if ((c.get(i) == 'e') && (c.get(i+1) == 's') && (c.get(i+2) == 'a') && (c.get(i+3) == 'r') && (c.get(i+4) == 'e')) {
				i += 5;
				if (i >= s.length()) break;
				continue;
			} (c.get(i) == 'e') && (c.get(i+1) == 's') && (c.get(i+2) == 'a') && (c.get(i+3) == 'r') && (c.get(i+4) == 'e') (c.get(i+3) == 'r') (c.get(i+2) == 'a') (c.get(i) == 'e') && (c.get(i+1) == 's') && (c.get(i+2) == 'a') && (c.get(i+3) == 'r') && (c.get(i+4) == 'e') (c.get(i) == 'e') c.get(i) c.get c i 'e' (c.get(i+1) == 's') c.get(i+1) c.get c i+1 i 1 's' (c.get(i+2) == 'a') c.get(i+2) c.get c i+2 i 2 'a' (c.get(i+3) == 'r') c.get(i+3) c.get c i+3 i 3 'r' (c.get(i+4) == 'e') c.get(i+4) c.get c i+4 i 4 'e' {
				i += 5;
				if (i >= s.length()) break;
				continue;
			} i += 5 i 5 if (i >= s.length()) break; i >= s.length() i s.length() s.length s break; continue; if ((c.get(i) == 'r') && (c.get(i+1) == 'e') && (c.get(i+2) == 'm') && (c.get(i+3) == 'a') && (c.get(i+4) == 'e') && (c.get(i+5) == 'r') && (c.get(i+6) == 'd')) {
				i += 7;
				if (i >= s.length()) break;
				continue;
			} (c.get(i) == 'r') && (c.get(i+1) == 'e') && (c.get(i+2) == 'm') && (c.get(i+3) == 'a') && (c.get(i+4) == 'e') && (c.get(i+5) == 'r') && (c.get(i+6) == 'd') (c.get(i+5) == 'r') (c.get(i+4) == 'e') (c.get(i+3) == 'a') (c.get(i+2) == 'm') (c.get(i) == 'r') && (c.get(i+1) == 'e') && (c.get(i+2) == 'm') && (c.get(i+3) == 'a') && (c.get(i+4) == 'e') && (c.get(i+5) == 'r') && (c.get(i+6) == 'd') (c.get(i) == 'r') c.get(i) c.get c i 'r' (c.get(i+1) == 'e') c.get(i+1) c.get c i+1 i 1 'e' (c.get(i+2) == 'm') c.get(i+2) c.get c i+2 i 2 'm' (c.get(i+3) == 'a') c.get(i+3) c.get c i+3 i 3 'a' (c.get(i+4) == 'e') c.get(i+4) c.get c i+4 i 4 'e' (c.get(i+5) == 'r') c.get(i+5) c.get c i+5 i 5 'r' (c.get(i+6) == 'd') c.get(i+6) c.get c i+6 i 6 'd' {
				i += 7;
				if (i >= s.length()) break;
				continue;
			} i += 7 i 7 if (i >= s.length()) break; i >= s.length() i s.length() s.length s break; continue; if ((c.get(i) == 'r') && (c.get(i+1) == 'e') && (c.get(i+2) == 's') && (c.get(i+3) == 'a') && (c.get(i+4) == 'r') && (c.get(i+5) == 'e')) {
				i += 6;
				if (i >= s.length()) break;
				continue;
			} (c.get(i) == 'r') && (c.get(i+1) == 'e') && (c.get(i+2) == 's') && (c.get(i+3) == 'a') && (c.get(i+4) == 'r') && (c.get(i+5) == 'e') (c.get(i+4) == 'r') (c.get(i+3) == 'a') (c.get(i+2) == 's') (c.get(i) == 'r') && (c.get(i+1) == 'e') && (c.get(i+2) == 's') && (c.get(i+3) == 'a') && (c.get(i+4) == 'r') && (c.get(i+5) == 'e') (c.get(i) == 'r') c.get(i) c.get c i 'r' (c.get(i+1) == 'e') c.get(i+1) c.get c i+1 i 1 'e' (c.get(i+2) == 's') c.get(i+2) c.get c i+2 i 2 's' (c.get(i+3) == 'a') c.get(i+3) c.get c i+3 i 3 'a' (c.get(i+4) == 'r') c.get(i+4) c.get c i+4 i 4 'r' (c.get(i+5) == 'e') c.get(i+5) c.get c i+5 i 5 'e' {
				i += 6;
				if (i >= s.length()) break;
				continue;
			} i += 6 i 6 if (i >= s.length()) break; i >= s.length() i s.length() s.length s break; continue; f = false f false if (f) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		} f {
			System.out.println("YES");
		} System.out.println("YES") System.out.println System.out System System.out "YES" {
			System.out.println("NO");
		} System.out.println("NO") System.out.println System.out System System.out "NO" String[] args args public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		ArrayList<Character> c = new ArrayList<Character>();
		for (int i = 0; i < s.length(); i++) {
			c.add(s.charAt(i));
		}
		Collections.reverse(c);
		boolean f = true;
		int i = 0;
		while(f) {
			if ((c.get(i) == 'm') && (c.get(i+1) == 'a') && (c.get(i+2) == 'e') && (c.get(i+3) == 'r') && (c.get(i+4) == 'd')) {
				i += 5;
				if (i >= s.length()) break;
				continue;
			}
			if ((c.get(i) == 'e') && (c.get(i+1) == 's') && (c.get(i+2) == 'a') && (c.get(i+3) == 'r') && (c.get(i+4) == 'e')) {
				i += 5;
				if (i >= s.length()) break;
				continue;
			}
			if ((c.get(i) == 'r') && (c.get(i+1) == 'e') && (c.get(i+2) == 'm') && (c.get(i+3) == 'a') && (c.get(i+4) == 'e') && (c.get(i+5) == 'r') && (c.get(i+6) == 'd')) {
				i += 7;
				if (i >= s.length()) break;
				continue;
			}
			if ((c.get(i) == 'r') && (c.get(i+1) == 'e') && (c.get(i+2) == 's') && (c.get(i+3) == 'a') && (c.get(i+4) == 'r') && (c.get(i+5) == 'e')) {
				i += 6;
				if (i >= s.length()) break;
				continue;
			}
			f = false;
		}
		if (f) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
} public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		ArrayList<Character> c = new ArrayList<Character>();
		for (int i = 0; i < s.length(); i++) {
			c.add(s.charAt(i));
		}
		Collections.reverse(c);
		boolean f = true;
		int i = 0;
		while(f) {
			if ((c.get(i) == 'm') && (c.get(i+1) == 'a') && (c.get(i+2) == 'e') && (c.get(i+3) == 'r') && (c.get(i+4) == 'd')) {
				i += 5;
				if (i >= s.length()) break;
				continue;
			}
			if ((c.get(i) == 'e') && (c.get(i+1) == 's') && (c.get(i+2) == 'a') && (c.get(i+3) == 'r') && (c.get(i+4) == 'e')) {
				i += 5;
				if (i >= s.length()) break;
				continue;
			}
			if ((c.get(i) == 'r') && (c.get(i+1) == 'e') && (c.get(i+2) == 'm') && (c.get(i+3) == 'a') && (c.get(i+4) == 'e') && (c.get(i+5) == 'r') && (c.get(i+6) == 'd')) {
				i += 7;
				if (i >= s.length()) break;
				continue;
			}
			if ((c.get(i) == 'r') && (c.get(i+1) == 'e') && (c.get(i+2) == 's') && (c.get(i+3) == 'a') && (c.get(i+4) == 'r') && (c.get(i+5) == 'e')) {
				i += 6;
				if (i >= s.length()) break;
				continue;
			}
			f = false;
		}
		if (f) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
} Main
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		ArrayList<Character> c = new ArrayList<Character>();
		for (int i = 0; i < s.length(); i++) {
			c.add(s.charAt(i));
		}
		Collections.reverse(c);
		boolean f = true;
		int i = 0;
		while(f) {
			if ((c.get(i) == 'm') && (c.get(i+1) == 'a') && (c.get(i+2) == 'e') && (c.get(i+3) == 'r') && (c.get(i+4) == 'd')) {
				i += 5;
				if (i >= s.length()) break;
				continue;
			}
			if ((c.get(i) == 'e') && (c.get(i+1) == 's') && (c.get(i+2) == 'a') && (c.get(i+3) == 'r') && (c.get(i+4) == 'e')) {
				i += 5;
				if (i >= s.length()) break;
				continue;
			}
			if ((c.get(i) == 'r') && (c.get(i+1) == 'e') && (c.get(i+2) == 'm') && (c.get(i+3) == 'a') && (c.get(i+4) == 'e') && (c.get(i+5) == 'r') && (c.get(i+6) == 'd')) {
				i += 7;
				if (i >= s.length()) break;
				continue;
			}
			if ((c.get(i) == 'r') && (c.get(i+1) == 'e') && (c.get(i+2) == 's') && (c.get(i+3) == 'a') && (c.get(i+4) == 'r') && (c.get(i+5) == 'e')) {
				i += 6;
				if (i >= s.length()) break;
				continue;
			}
			f = false;
		}
		if (f) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}
