import java.util.*;
class Main{
	static Scanner s = new Scanner(System.in);
	public static void main(String[] args) {
		StringBuilder str = new StringBuilder(s.next()
				.replaceAll("eraser", "")
				.replaceAll("dream", "D")
				.replaceAll("er", "R")
				.replaceAll("as", "A"));
		String[] m = {"RAe","DR","D"};
		String b,st;
		boolean f;
		do {
			f=false;
			for(int i=0;i<m.length;i++) {
				b=m[i];
				st = str.toString();
				if(st.endsWith(b)) {
					str.delete(str.length()-b.length(),str.length());
					f=true;
					break;
				}
			}
		}while(f);
		System.out.println((str.toString().equals(""))?"YES":"NO");
	}
} import java.util.*; util.* java class Main{
	static Scanner s = new Scanner(System.in);
	public static void main(String[] args) {
		StringBuilder str = new StringBuilder(s.next()
				.replaceAll("eraser", "")
				.replaceAll("dream", "D")
				.replaceAll("er", "R")
				.replaceAll("as", "A"));
		String[] m = {"RAe","DR","D"};
		String b,st;
		boolean f;
		do {
			f=false;
			for(int i=0;i<m.length;i++) {
				b=m[i];
				st = str.toString();
				if(st.endsWith(b)) {
					str.delete(str.length()-b.length(),str.length());
					f=true;
					break;
				}
			}
		}while(f);
		System.out.println((str.toString().equals(""))?"YES":"NO");
	}
} Main static Scanner s = new Scanner(System.in); s new Scanner(System.in) public static void main(String[] args) {
		StringBuilder str = new StringBuilder(s.next()
				.replaceAll("eraser", "")
				.replaceAll("dream", "D")
				.replaceAll("er", "R")
				.replaceAll("as", "A"));
		String[] m = {"RAe","DR","D"};
		String b,st;
		boolean f;
		do {
			f=false;
			for(int i=0;i<m.length;i++) {
				b=m[i];
				st = str.toString();
				if(st.endsWith(b)) {
					str.delete(str.length()-b.length(),str.length());
					f=true;
					break;
				}
			}
		}while(f);
		System.out.println((str.toString().equals(""))?"YES":"NO");
	} main {
		StringBuilder str = new StringBuilder(s.next()
				.replaceAll("eraser", "")
				.replaceAll("dream", "D")
				.replaceAll("er", "R")
				.replaceAll("as", "A"));
		String[] m = {"RAe","DR","D"};
		String b,st;
		boolean f;
		do {
			f=false;
			for(int i=0;i<m.length;i++) {
				b=m[i];
				st = str.toString();
				if(st.endsWith(b)) {
					str.delete(str.length()-b.length(),str.length());
					f=true;
					break;
				}
			}
		}while(f);
		System.out.println((str.toString().equals(""))?"YES":"NO");
	} StringBuilder str = new StringBuilder(s.next()
				.replaceAll("eraser", "")
				.replaceAll("dream", "D")
				.replaceAll("er", "R")
				.replaceAll("as", "A")); str new StringBuilder(s.next()
				.replaceAll("eraser", "")
				.replaceAll("dream", "D")
				.replaceAll("er", "R")
				.replaceAll("as", "A")) String[] m = {"RAe","DR","D"}; m {"RAe","DR","D"} "RAe" "DR" "D" String b b st; st boolean f; f do {
			f=false;
			for(int i=0;i<m.length;i++) {
				b=m[i];
				st = str.toString();
				if(st.endsWith(b)) {
					str.delete(str.length()-b.length(),str.length());
					f=true;
					break;
				}
			}
		}while(f); f {
			f=false;
			for(int i=0;i<m.length;i++) {
				b=m[i];
				st = str.toString();
				if(st.endsWith(b)) {
					str.delete(str.length()-b.length(),str.length());
					f=true;
					break;
				}
			}
		} f=false f false for(int i=0;i<m.length;i++) {
				b=m[i];
				st = str.toString();
				if(st.endsWith(b)) {
					str.delete(str.length()-b.length(),str.length());
					f=true;
					break;
				}
			} int i=0; int i=0; i 0 i<m.length i m.length m m.length i++ i++ i {
				b=m[i];
				st = str.toString();
				if(st.endsWith(b)) {
					str.delete(str.length()-b.length(),str.length());
					f=true;
					break;
				}
			} {
				b=m[i];
				st = str.toString();
				if(st.endsWith(b)) {
					str.delete(str.length()-b.length(),str.length());
					f=true;
					break;
				}
			} b=m[i] b m[i] m i st = str.toString() st str.toString() str.toString str if(st.endsWith(b)) {
					str.delete(str.length()-b.length(),str.length());
					f=true;
					break;
				} st.endsWith(b) st.endsWith st b {
					str.delete(str.length()-b.length(),str.length());
					f=true;
					break;
				} str.delete(str.length()-b.length(),str.length()) str.delete str str.length()-b.length() str.length() str.length str b.length() b.length b str.length() str.length str f=true f true break; System.out.println((str.toString().equals(""))?"YES":"NO") System.out.println System.out System System.out (str.toString().equals(""))?"YES":"NO" (str.toString().equals("")) str.toString().equals str.toString() str.toString str "" "YES" "NO" String[] args args
import java.util.*;
class Main{
	static Scanner s = new Scanner(System.in);
	public static void main(String[] args) {
		StringBuilder str = new StringBuilder(s.next()
				.replaceAll("eraser", "")
				.replaceAll("dream", "D")
				.replaceAll("er", "R")
				.replaceAll("as", "A"));
		String[] m = {"RAe","DR","D"};
		String b,st;
		boolean f;
		do {
			f=false;
			for(int i=0;i<m.length;i++) {
				b=m[i];
				st = str.toString();
				if(st.endsWith(b)) {
					str.delete(str.length()-b.length(),str.length());
					f=true;
					break;
				}
			}
		}while(f);
		System.out.println((str.toString().equals(""))?"YES":"NO");
	}
}