import java.util.*;
public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        Set<String> set = new HashSet<String>();
        set.add("dream");
        set.add("dreamer");
        set.add("erase");
        set.add("eraser");
        int idx = s.length();
        String curr = "";
        while (idx >= 5) {
            if (set.contains(s.substring(idx - 5, idx))) {
                idx -= 5;
            } else if (set.contains(s.substring(idx - 6, idx))) {
                idx -= 6;
            } else if (set.contains(s.substring(idx - 7, idx))){ 
                idx -= 7;
            } else {
                break;
            }
        }
        String res =  idx == 0 ? "YES" : "NO";
        System.out.println(res);
    }
} import java.util.*; util.* java public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        Set<String> set = new HashSet<String>();
        set.add("dream");
        set.add("dreamer");
        set.add("erase");
        set.add("eraser");
        int idx = s.length();
        String curr = "";
        while (idx >= 5) {
            if (set.contains(s.substring(idx - 5, idx))) {
                idx -= 5;
            } else if (set.contains(s.substring(idx - 6, idx))) {
                idx -= 6;
            } else if (set.contains(s.substring(idx - 7, idx))){ 
                idx -= 7;
            } else {
                break;
            }
        }
        String res =  idx == 0 ? "YES" : "NO";
        System.out.println(res);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        Set<String> set = new HashSet<String>();
        set.add("dream");
        set.add("dreamer");
        set.add("erase");
        set.add("eraser");
        int idx = s.length();
        String curr = "";
        while (idx >= 5) {
            if (set.contains(s.substring(idx - 5, idx))) {
                idx -= 5;
            } else if (set.contains(s.substring(idx - 6, idx))) {
                idx -= 6;
            } else if (set.contains(s.substring(idx - 7, idx))){ 
                idx -= 7;
            } else {
                break;
            }
        }
        String res =  idx == 0 ? "YES" : "NO";
        System.out.println(res);
    } main {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        Set<String> set = new HashSet<String>();
        set.add("dream");
        set.add("dreamer");
        set.add("erase");
        set.add("eraser");
        int idx = s.length();
        String curr = "";
        while (idx >= 5) {
            if (set.contains(s.substring(idx - 5, idx))) {
                idx -= 5;
            } else if (set.contains(s.substring(idx - 6, idx))) {
                idx -= 6;
            } else if (set.contains(s.substring(idx - 7, idx))){ 
                idx -= 7;
            } else {
                break;
            }
        }
        String res =  idx == 0 ? "YES" : "NO";
        System.out.println(res);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s = sc.next(); s sc.next() sc.next sc Set<String> set = new HashSet<String>(); set new HashSet<String>() set.add("dream") set.add set "dream" set.add("dreamer") set.add set "dreamer" set.add("erase") set.add set "erase" set.add("eraser") set.add set "eraser" int idx = s.length(); idx s.length() s.length s String curr = ""; curr "" while (idx >= 5) {
            if (set.contains(s.substring(idx - 5, idx))) {
                idx -= 5;
            } else if (set.contains(s.substring(idx - 6, idx))) {
                idx -= 6;
            } else if (set.contains(s.substring(idx - 7, idx))){ 
                idx -= 7;
            } else {
                break;
            }
        } idx >= 5 idx 5 {
            if (set.contains(s.substring(idx - 5, idx))) {
                idx -= 5;
            } else if (set.contains(s.substring(idx - 6, idx))) {
                idx -= 6;
            } else if (set.contains(s.substring(idx - 7, idx))){ 
                idx -= 7;
            } else {
                break;
            }
        } if (set.contains(s.substring(idx - 5, idx))) {
                idx -= 5;
            } else if (set.contains(s.substring(idx - 6, idx))) {
                idx -= 6;
            } else if (set.contains(s.substring(idx - 7, idx))){ 
                idx -= 7;
            } else {
                break;
            } set.contains(s.substring(idx - 5, idx)) set.contains set s.substring(idx - 5, idx) s.substring s idx - 5 idx 5 idx {
                idx -= 5;
            } idx -= 5 idx 5 if (set.contains(s.substring(idx - 6, idx))) {
                idx -= 6;
            } else if (set.contains(s.substring(idx - 7, idx))){ 
                idx -= 7;
            } else {
                break;
            } set.contains(s.substring(idx - 6, idx)) set.contains set s.substring(idx - 6, idx) s.substring s idx - 6 idx 6 idx {
                idx -= 6;
            } idx -= 6 idx 6 if (set.contains(s.substring(idx - 7, idx))){ 
                idx -= 7;
            } else {
                break;
            } set.contains(s.substring(idx - 7, idx)) set.contains set s.substring(idx - 7, idx) s.substring s idx - 7 idx 7 idx { 
                idx -= 7;
            } idx -= 7 idx 7 {
                break;
            } break; String res =  idx == 0 ? "YES" : "NO"; res idx == 0 ? "YES" : "NO" idx == 0 idx 0 "YES" "NO" System.out.println(res) System.out.println System.out System System.out res String[] args args public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        Set<String> set = new HashSet<String>();
        set.add("dream");
        set.add("dreamer");
        set.add("erase");
        set.add("eraser");
        int idx = s.length();
        String curr = "";
        while (idx >= 5) {
            if (set.contains(s.substring(idx - 5, idx))) {
                idx -= 5;
            } else if (set.contains(s.substring(idx - 6, idx))) {
                idx -= 6;
            } else if (set.contains(s.substring(idx - 7, idx))){ 
                idx -= 7;
            } else {
                break;
            }
        }
        String res =  idx == 0 ? "YES" : "NO";
        System.out.println(res);
    }
} public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        Set<String> set = new HashSet<String>();
        set.add("dream");
        set.add("dreamer");
        set.add("erase");
        set.add("eraser");
        int idx = s.length();
        String curr = "";
        while (idx >= 5) {
            if (set.contains(s.substring(idx - 5, idx))) {
                idx -= 5;
            } else if (set.contains(s.substring(idx - 6, idx))) {
                idx -= 6;
            } else if (set.contains(s.substring(idx - 7, idx))){ 
                idx -= 7;
            } else {
                break;
            }
        }
        String res =  idx == 0 ? "YES" : "NO";
        System.out.println(res);
    }
} Main
import java.util.*;
public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        Set<String> set = new HashSet<String>();
        set.add("dream");
        set.add("dreamer");
        set.add("erase");
        set.add("eraser");
        int idx = s.length();
        String curr = "";
        while (idx >= 5) {
            if (set.contains(s.substring(idx - 5, idx))) {
                idx -= 5;
            } else if (set.contains(s.substring(idx - 6, idx))) {
                idx -= 6;
            } else if (set.contains(s.substring(idx - 7, idx))){ 
                idx -= 7;
            } else {
                break;
            }
        }
        String res =  idx == 0 ? "YES" : "NO";
        System.out.println(res);
    }
}
