import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        String S = cin.next();

        String[] words = {"dream", "dreamer", "erase", "eraser"};

        Queue<Integer> q = new ArrayDeque<>();
        q.add(0);

        boolean matched = false;
        while (!q.isEmpty()) {
            int i = q.poll();
            if (i == S.length()) {
                matched = true;
                break;
            }

            for (String word : words) {
                int end = i + word.length();
                if (end > S.length()) {
                    continue;
                }
                if (S.substring(i, end).equals(word)) {
                    q.add(end);
                }
            }
        }

        if (matched) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        String S = cin.next();

        String[] words = {"dream", "dreamer", "erase", "eraser"};

        Queue<Integer> q = new ArrayDeque<>();
        q.add(0);

        boolean matched = false;
        while (!q.isEmpty()) {
            int i = q.poll();
            if (i == S.length()) {
                matched = true;
                break;
            }

            for (String word : words) {
                int end = i + word.length();
                if (end > S.length()) {
                    continue;
                }
                if (S.substring(i, end).equals(word)) {
                    q.add(end);
                }
            }
        }

        if (matched) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
} Main public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        String S = cin.next();

        String[] words = {"dream", "dreamer", "erase", "eraser"};

        Queue<Integer> q = new ArrayDeque<>();
        q.add(0);

        boolean matched = false;
        while (!q.isEmpty()) {
            int i = q.poll();
            if (i == S.length()) {
                matched = true;
                break;
            }

            for (String word : words) {
                int end = i + word.length();
                if (end > S.length()) {
                    continue;
                }
                if (S.substring(i, end).equals(word)) {
                    q.add(end);
                }
            }
        }

        if (matched) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    } main {
        Scanner cin = new Scanner(System.in);
        String S = cin.next();

        String[] words = {"dream", "dreamer", "erase", "eraser"};

        Queue<Integer> q = new ArrayDeque<>();
        q.add(0);

        boolean matched = false;
        while (!q.isEmpty()) {
            int i = q.poll();
            if (i == S.length()) {
                matched = true;
                break;
            }

            for (String word : words) {
                int end = i + word.length();
                if (end > S.length()) {
                    continue;
                }
                if (S.substring(i, end).equals(word)) {
                    q.add(end);
                }
            }
        }

        if (matched) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    } Scanner cin = new Scanner(System.in); cin new Scanner(System.in) String S = cin.next(); S cin.next() cin.next cin String[] words = {"dream", "dreamer", "erase", "eraser"}; words {"dream", "dreamer", "erase", "eraser"} "dream" "dreamer" "erase" "eraser" Queue<Integer> q = new ArrayDeque<>(); q new ArrayDeque<>() q.add(0) q.add q 0 boolean matched = false; matched false while (!q.isEmpty()) {
            int i = q.poll();
            if (i == S.length()) {
                matched = true;
                break;
            }

            for (String word : words) {
                int end = i + word.length();
                if (end > S.length()) {
                    continue;
                }
                if (S.substring(i, end).equals(word)) {
                    q.add(end);
                }
            }
        } !q.isEmpty() q.isEmpty() q.isEmpty q {
            int i = q.poll();
            if (i == S.length()) {
                matched = true;
                break;
            }

            for (String word : words) {
                int end = i + word.length();
                if (end > S.length()) {
                    continue;
                }
                if (S.substring(i, end).equals(word)) {
                    q.add(end);
                }
            }
        } int i = q.poll(); i q.poll() q.poll q if (i == S.length()) {
                matched = true;
                break;
            } i == S.length() i S.length() S.length S {
                matched = true;
                break;
            } matched = true matched true break; for (String word : words) {
                int end = i + word.length();
                if (end > S.length()) {
                    continue;
                }
                if (S.substring(i, end).equals(word)) {
                    q.add(end);
                }
            } String word words {
                int end = i + word.length();
                if (end > S.length()) {
                    continue;
                }
                if (S.substring(i, end).equals(word)) {
                    q.add(end);
                }
            } {
                int end = i + word.length();
                if (end > S.length()) {
                    continue;
                }
                if (S.substring(i, end).equals(word)) {
                    q.add(end);
                }
            } int end = i + word.length(); end i + word.length() i word.length() word.length word if (end > S.length()) {
                    continue;
                } end > S.length() end S.length() S.length S {
                    continue;
                } continue; if (S.substring(i, end).equals(word)) {
                    q.add(end);
                } S.substring(i, end).equals(word) S.substring(i, end).equals S.substring(i, end) S.substring S i end word {
                    q.add(end);
                } q.add(end) q.add q end if (matched) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        } matched {
            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 cin = new Scanner(System.in);
        String S = cin.next();

        String[] words = {"dream", "dreamer", "erase", "eraser"};

        Queue<Integer> q = new ArrayDeque<>();
        q.add(0);

        boolean matched = false;
        while (!q.isEmpty()) {
            int i = q.poll();
            if (i == S.length()) {
                matched = true;
                break;
            }

            for (String word : words) {
                int end = i + word.length();
                if (end > S.length()) {
                    continue;
                }
                if (S.substring(i, end).equals(word)) {
                    q.add(end);
                }
            }
        }

        if (matched) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
} public class Main {
    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        String S = cin.next();

        String[] words = {"dream", "dreamer", "erase", "eraser"};

        Queue<Integer> q = new ArrayDeque<>();
        q.add(0);

        boolean matched = false;
        while (!q.isEmpty()) {
            int i = q.poll();
            if (i == S.length()) {
                matched = true;
                break;
            }

            for (String word : words) {
                int end = i + word.length();
                if (end > S.length()) {
                    continue;
                }
                if (S.substring(i, end).equals(word)) {
                    q.add(end);
                }
            }
        }

        if (matched) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        String S = cin.next();

        String[] words = {"dream", "dreamer", "erase", "eraser"};

        Queue<Integer> q = new ArrayDeque<>();
        q.add(0);

        boolean matched = false;
        while (!q.isEmpty()) {
            int i = q.poll();
            if (i == S.length()) {
                matched = true;
                break;
            }

            for (String word : words) {
                int end = i + word.length();
                if (end > S.length()) {
                    continue;
                }
                if (S.substring(i, end).equals(word)) {
                    q.add(end);
                }
            }
        }

        if (matched) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}
