import java.util.*;
import java.util.regex.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // 入力
        String s = sc.next();
        // 文字列反転処理
        StringBuffer sb = new StringBuffer(s);
        String reversedStr = sb.reverse().toString();
        
        // 文字列反転リスト
        List<String> list = Arrays.asList("dream", "dreamer", "erase", "eraser");
        List<String> reversedList = new ArrayList<>();
        for (String str : list) {
            sb.setLength(0);
            sb.append(str);
            reversedList.add(sb.reverse().toString());
        }

        // 正規表現
        String ptnStr = "^(" + String.join("|", reversedList) + ")+$";
        Pattern pattern = Pattern.compile(ptnStr);
        Matcher matcher = pattern.matcher(reversedStr);

        if (matcher.matches()) {
            // 出力
            System.out.println("YES");
        } else {
            // 出力
            System.out.println("NO");
        }
    }
} import java.util.*; util.* java import java.util.regex.*; regex.* java.util public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // 入力
        String s = sc.next();
        // 文字列反転処理
        StringBuffer sb = new StringBuffer(s);
        String reversedStr = sb.reverse().toString();
        
        // 文字列反転リスト
        List<String> list = Arrays.asList("dream", "dreamer", "erase", "eraser");
        List<String> reversedList = new ArrayList<>();
        for (String str : list) {
            sb.setLength(0);
            sb.append(str);
            reversedList.add(sb.reverse().toString());
        }

        // 正規表現
        String ptnStr = "^(" + String.join("|", reversedList) + ")+$";
        Pattern pattern = Pattern.compile(ptnStr);
        Matcher matcher = pattern.matcher(reversedStr);

        if (matcher.matches()) {
            // 出力
            System.out.println("YES");
        } else {
            // 出力
            System.out.println("NO");
        }
    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // 入力
        String s = sc.next();
        // 文字列反転処理
        StringBuffer sb = new StringBuffer(s);
        String reversedStr = sb.reverse().toString();
        
        // 文字列反転リスト
        List<String> list = Arrays.asList("dream", "dreamer", "erase", "eraser");
        List<String> reversedList = new ArrayList<>();
        for (String str : list) {
            sb.setLength(0);
            sb.append(str);
            reversedList.add(sb.reverse().toString());
        }

        // 正規表現
        String ptnStr = "^(" + String.join("|", reversedList) + ")+$";
        Pattern pattern = Pattern.compile(ptnStr);
        Matcher matcher = pattern.matcher(reversedStr);

        if (matcher.matches()) {
            // 出力
            System.out.println("YES");
        } else {
            // 出力
            System.out.println("NO");
        }
    } main {
        Scanner sc = new Scanner(System.in);
        // 入力
        String s = sc.next();
        // 文字列反転処理
        StringBuffer sb = new StringBuffer(s);
        String reversedStr = sb.reverse().toString();
        
        // 文字列反転リスト
        List<String> list = Arrays.asList("dream", "dreamer", "erase", "eraser");
        List<String> reversedList = new ArrayList<>();
        for (String str : list) {
            sb.setLength(0);
            sb.append(str);
            reversedList.add(sb.reverse().toString());
        }

        // 正規表現
        String ptnStr = "^(" + String.join("|", reversedList) + ")+$";
        Pattern pattern = Pattern.compile(ptnStr);
        Matcher matcher = pattern.matcher(reversedStr);

        if (matcher.matches()) {
            // 出力
            System.out.println("YES");
        } else {
            // 出力
            System.out.println("NO");
        }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s = sc.next(); s sc.next() sc.next sc StringBuffer sb = new StringBuffer(s); sb new StringBuffer(s) String reversedStr = sb.reverse().toString(); reversedStr sb.reverse().toString() sb.reverse().toString sb.reverse() sb.reverse sb List<String> list = Arrays.asList("dream", "dreamer", "erase", "eraser"); list Arrays.asList("dream", "dreamer", "erase", "eraser") Arrays.asList Arrays "dream" "dreamer" "erase" "eraser" List<String> reversedList = new ArrayList<>(); reversedList new ArrayList<>() for (String str : list) {
            sb.setLength(0);
            sb.append(str);
            reversedList.add(sb.reverse().toString());
        } String str list {
            sb.setLength(0);
            sb.append(str);
            reversedList.add(sb.reverse().toString());
        } {
            sb.setLength(0);
            sb.append(str);
            reversedList.add(sb.reverse().toString());
        } sb.setLength(0) sb.setLength sb 0 sb.append(str) sb.append sb str reversedList.add(sb.reverse().toString()) reversedList.add reversedList sb.reverse().toString() sb.reverse().toString sb.reverse() sb.reverse sb String ptnStr = "^(" + String.join("|", reversedList) + ")+$"; ptnStr "^(" + String.join("|", reversedList) + ")+$" "^(" + String.join("|", reversedList) + ")+$" "^(" String.join("|", reversedList) String.join String "|" reversedList ")+$" Pattern pattern = Pattern.compile(ptnStr); pattern Pattern.compile(ptnStr) Pattern.compile Pattern ptnStr Matcher matcher = pattern.matcher(reversedStr); matcher pattern.matcher(reversedStr) pattern.matcher pattern reversedStr if (matcher.matches()) {
            // 出力
            System.out.println("YES");
        } else {
            // 出力
            System.out.println("NO");
        } matcher.matches() matcher.matches matcher {
            // 出力
            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 sc = new Scanner(System.in);
        // 入力
        String s = sc.next();
        // 文字列反転処理
        StringBuffer sb = new StringBuffer(s);
        String reversedStr = sb.reverse().toString();
        
        // 文字列反転リスト
        List<String> list = Arrays.asList("dream", "dreamer", "erase", "eraser");
        List<String> reversedList = new ArrayList<>();
        for (String str : list) {
            sb.setLength(0);
            sb.append(str);
            reversedList.add(sb.reverse().toString());
        }

        // 正規表現
        String ptnStr = "^(" + String.join("|", reversedList) + ")+$";
        Pattern pattern = Pattern.compile(ptnStr);
        Matcher matcher = pattern.matcher(reversedStr);

        if (matcher.matches()) {
            // 出力
            System.out.println("YES");
        } else {
            // 出力
            System.out.println("NO");
        }
    }
} public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // 入力
        String s = sc.next();
        // 文字列反転処理
        StringBuffer sb = new StringBuffer(s);
        String reversedStr = sb.reverse().toString();
        
        // 文字列反転リスト
        List<String> list = Arrays.asList("dream", "dreamer", "erase", "eraser");
        List<String> reversedList = new ArrayList<>();
        for (String str : list) {
            sb.setLength(0);
            sb.append(str);
            reversedList.add(sb.reverse().toString());
        }

        // 正規表現
        String ptnStr = "^(" + String.join("|", reversedList) + ")+$";
        Pattern pattern = Pattern.compile(ptnStr);
        Matcher matcher = pattern.matcher(reversedStr);

        if (matcher.matches()) {
            // 出力
            System.out.println("YES");
        } else {
            // 出力
            System.out.println("NO");
        }
    }
} Main
import java.util.*;
import java.util.regex.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // 入力
        String s = sc.next();
        // 文字列反転処理
        StringBuffer sb = new StringBuffer(s);
        String reversedStr = sb.reverse().toString();
        
        // 文字列反転リスト
        List<String> list = Arrays.asList("dream", "dreamer", "erase", "eraser");
        List<String> reversedList = new ArrayList<>();
        for (String str : list) {
            sb.setLength(0);
            sb.append(str);
            reversedList.add(sb.reverse().toString());
        }

        // 正規表現
        String ptnStr = "^(" + String.join("|", reversedList) + ")+$";
        Pattern pattern = Pattern.compile(ptnStr);
        Matcher matcher = pattern.matcher(reversedStr);

        if (matcher.matches()) {
            // 出力
            System.out.println("YES");
        } else {
            // 出力
            System.out.println("NO");
        }
    }
}
