import java.util.Arrays;
import java.util.LinkedHashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        if (s.length() < 5) {
            System.out.println("NO");
            return;
        }
        String[] ary = {"dreamer", "eraser", "dream", "erase"};
        Set<String> set = new LinkedHashSet<>(Arrays.asList(ary));
        int idx = s.length() - 1;
        while (idx >= 0) {
            boolean isMatch = false;
            if (idx - 6 >= 0) {
                isMatch = set.contains(s.substring(idx - 6, idx + 1));
                if (isMatch) {
                    idx -= 7;
                }
            }
            if (!isMatch && idx - 5 >= 0) {
                isMatch = set.contains(s.substring(idx - 5, idx + 1));
                if (isMatch) {
                    idx -= 6;
                }
            }
            if (!isMatch && idx - 4 >= 0) {
                isMatch = set.contains(s.substring(idx - 4, idx + 1));
                if (isMatch) {
                    idx -= 5;
                }
            }
            if (!isMatch) {
                System.out.println("NO");
                return;
            }
        }
        System.out.println("YES");
    }
} import java.util.Arrays; Arrays java.util import java.util.LinkedHashSet; LinkedHashSet java.util import java.util.Scanner; Scanner java.util import java.util.Set; Set java.util public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        if (s.length() < 5) {
            System.out.println("NO");
            return;
        }
        String[] ary = {"dreamer", "eraser", "dream", "erase"};
        Set<String> set = new LinkedHashSet<>(Arrays.asList(ary));
        int idx = s.length() - 1;
        while (idx >= 0) {
            boolean isMatch = false;
            if (idx - 6 >= 0) {
                isMatch = set.contains(s.substring(idx - 6, idx + 1));
                if (isMatch) {
                    idx -= 7;
                }
            }
            if (!isMatch && idx - 5 >= 0) {
                isMatch = set.contains(s.substring(idx - 5, idx + 1));
                if (isMatch) {
                    idx -= 6;
                }
            }
            if (!isMatch && idx - 4 >= 0) {
                isMatch = set.contains(s.substring(idx - 4, idx + 1));
                if (isMatch) {
                    idx -= 5;
                }
            }
            if (!isMatch) {
                System.out.println("NO");
                return;
            }
        }
        System.out.println("YES");
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        if (s.length() < 5) {
            System.out.println("NO");
            return;
        }
        String[] ary = {"dreamer", "eraser", "dream", "erase"};
        Set<String> set = new LinkedHashSet<>(Arrays.asList(ary));
        int idx = s.length() - 1;
        while (idx >= 0) {
            boolean isMatch = false;
            if (idx - 6 >= 0) {
                isMatch = set.contains(s.substring(idx - 6, idx + 1));
                if (isMatch) {
                    idx -= 7;
                }
            }
            if (!isMatch && idx - 5 >= 0) {
                isMatch = set.contains(s.substring(idx - 5, idx + 1));
                if (isMatch) {
                    idx -= 6;
                }
            }
            if (!isMatch && idx - 4 >= 0) {
                isMatch = set.contains(s.substring(idx - 4, idx + 1));
                if (isMatch) {
                    idx -= 5;
                }
            }
            if (!isMatch) {
                System.out.println("NO");
                return;
            }
        }
        System.out.println("YES");
    } main {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        if (s.length() < 5) {
            System.out.println("NO");
            return;
        }
        String[] ary = {"dreamer", "eraser", "dream", "erase"};
        Set<String> set = new LinkedHashSet<>(Arrays.asList(ary));
        int idx = s.length() - 1;
        while (idx >= 0) {
            boolean isMatch = false;
            if (idx - 6 >= 0) {
                isMatch = set.contains(s.substring(idx - 6, idx + 1));
                if (isMatch) {
                    idx -= 7;
                }
            }
            if (!isMatch && idx - 5 >= 0) {
                isMatch = set.contains(s.substring(idx - 5, idx + 1));
                if (isMatch) {
                    idx -= 6;
                }
            }
            if (!isMatch && idx - 4 >= 0) {
                isMatch = set.contains(s.substring(idx - 4, idx + 1));
                if (isMatch) {
                    idx -= 5;
                }
            }
            if (!isMatch) {
                System.out.println("NO");
                return;
            }
        }
        System.out.println("YES");
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s = sc.next(); s sc.next() sc.next sc if (s.length() < 5) {
            System.out.println("NO");
            return;
        } s.length() < 5 s.length() s.length s 5 {
            System.out.println("NO");
            return;
        } System.out.println("NO") System.out.println System.out System System.out "NO" return; String[] ary = {"dreamer", "eraser", "dream", "erase"}; ary {"dreamer", "eraser", "dream", "erase"} "dreamer" "eraser" "dream" "erase" Set<String> set = new LinkedHashSet<>(Arrays.asList(ary)); set new LinkedHashSet<>(Arrays.asList(ary)) int idx = s.length() - 1; idx s.length() - 1 s.length() s.length s 1 while (idx >= 0) {
            boolean isMatch = false;
            if (idx - 6 >= 0) {
                isMatch = set.contains(s.substring(idx - 6, idx + 1));
                if (isMatch) {
                    idx -= 7;
                }
            }
            if (!isMatch && idx - 5 >= 0) {
                isMatch = set.contains(s.substring(idx - 5, idx + 1));
                if (isMatch) {
                    idx -= 6;
                }
            }
            if (!isMatch && idx - 4 >= 0) {
                isMatch = set.contains(s.substring(idx - 4, idx + 1));
                if (isMatch) {
                    idx -= 5;
                }
            }
            if (!isMatch) {
                System.out.println("NO");
                return;
            }
        } idx >= 0 idx 0 {
            boolean isMatch = false;
            if (idx - 6 >= 0) {
                isMatch = set.contains(s.substring(idx - 6, idx + 1));
                if (isMatch) {
                    idx -= 7;
                }
            }
            if (!isMatch && idx - 5 >= 0) {
                isMatch = set.contains(s.substring(idx - 5, idx + 1));
                if (isMatch) {
                    idx -= 6;
                }
            }
            if (!isMatch && idx - 4 >= 0) {
                isMatch = set.contains(s.substring(idx - 4, idx + 1));
                if (isMatch) {
                    idx -= 5;
                }
            }
            if (!isMatch) {
                System.out.println("NO");
                return;
            }
        } boolean isMatch = false; isMatch false if (idx - 6 >= 0) {
                isMatch = set.contains(s.substring(idx - 6, idx + 1));
                if (isMatch) {
                    idx -= 7;
                }
            } idx - 6 >= 0 idx - 6 idx 6 0 {
                isMatch = set.contains(s.substring(idx - 6, idx + 1));
                if (isMatch) {
                    idx -= 7;
                }
            } isMatch = set.contains(s.substring(idx - 6, idx + 1)) isMatch set.contains(s.substring(idx - 6, idx + 1)) set.contains set s.substring(idx - 6, idx + 1) s.substring s idx - 6 idx 6 idx + 1 idx 1 if (isMatch) {
                    idx -= 7;
                } isMatch {
                    idx -= 7;
                } idx -= 7 idx 7 if (!isMatch && idx - 5 >= 0) {
                isMatch = set.contains(s.substring(idx - 5, idx + 1));
                if (isMatch) {
                    idx -= 6;
                }
            } !isMatch && idx - 5 >= 0 !isMatch isMatch idx - 5 >= 0 idx - 5 idx 5 0 {
                isMatch = set.contains(s.substring(idx - 5, idx + 1));
                if (isMatch) {
                    idx -= 6;
                }
            } isMatch = set.contains(s.substring(idx - 5, idx + 1)) isMatch set.contains(s.substring(idx - 5, idx + 1)) set.contains set s.substring(idx - 5, idx + 1) s.substring s idx - 5 idx 5 idx + 1 idx 1 if (isMatch) {
                    idx -= 6;
                } isMatch {
                    idx -= 6;
                } idx -= 6 idx 6 if (!isMatch && idx - 4 >= 0) {
                isMatch = set.contains(s.substring(idx - 4, idx + 1));
                if (isMatch) {
                    idx -= 5;
                }
            } !isMatch && idx - 4 >= 0 !isMatch isMatch idx - 4 >= 0 idx - 4 idx 4 0 {
                isMatch = set.contains(s.substring(idx - 4, idx + 1));
                if (isMatch) {
                    idx -= 5;
                }
            } isMatch = set.contains(s.substring(idx - 4, idx + 1)) isMatch set.contains(s.substring(idx - 4, idx + 1)) set.contains set s.substring(idx - 4, idx + 1) s.substring s idx - 4 idx 4 idx + 1 idx 1 if (isMatch) {
                    idx -= 5;
                } isMatch {
                    idx -= 5;
                } idx -= 5 idx 5 if (!isMatch) {
                System.out.println("NO");
                return;
            } !isMatch isMatch {
                System.out.println("NO");
                return;
            } System.out.println("NO") System.out.println System.out System System.out "NO" return; System.out.println("YES") System.out.println System.out System System.out "YES" String[] args args public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        if (s.length() < 5) {
            System.out.println("NO");
            return;
        }
        String[] ary = {"dreamer", "eraser", "dream", "erase"};
        Set<String> set = new LinkedHashSet<>(Arrays.asList(ary));
        int idx = s.length() - 1;
        while (idx >= 0) {
            boolean isMatch = false;
            if (idx - 6 >= 0) {
                isMatch = set.contains(s.substring(idx - 6, idx + 1));
                if (isMatch) {
                    idx -= 7;
                }
            }
            if (!isMatch && idx - 5 >= 0) {
                isMatch = set.contains(s.substring(idx - 5, idx + 1));
                if (isMatch) {
                    idx -= 6;
                }
            }
            if (!isMatch && idx - 4 >= 0) {
                isMatch = set.contains(s.substring(idx - 4, idx + 1));
                if (isMatch) {
                    idx -= 5;
                }
            }
            if (!isMatch) {
                System.out.println("NO");
                return;
            }
        }
        System.out.println("YES");
    }
} public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        if (s.length() < 5) {
            System.out.println("NO");
            return;
        }
        String[] ary = {"dreamer", "eraser", "dream", "erase"};
        Set<String> set = new LinkedHashSet<>(Arrays.asList(ary));
        int idx = s.length() - 1;
        while (idx >= 0) {
            boolean isMatch = false;
            if (idx - 6 >= 0) {
                isMatch = set.contains(s.substring(idx - 6, idx + 1));
                if (isMatch) {
                    idx -= 7;
                }
            }
            if (!isMatch && idx - 5 >= 0) {
                isMatch = set.contains(s.substring(idx - 5, idx + 1));
                if (isMatch) {
                    idx -= 6;
                }
            }
            if (!isMatch && idx - 4 >= 0) {
                isMatch = set.contains(s.substring(idx - 4, idx + 1));
                if (isMatch) {
                    idx -= 5;
                }
            }
            if (!isMatch) {
                System.out.println("NO");
                return;
            }
        }
        System.out.println("YES");
    }
} Main
import java.util.Arrays;
import java.util.LinkedHashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        if (s.length() < 5) {
            System.out.println("NO");
            return;
        }
        String[] ary = {"dreamer", "eraser", "dream", "erase"};
        Set<String> set = new LinkedHashSet<>(Arrays.asList(ary));
        int idx = s.length() - 1;
        while (idx >= 0) {
            boolean isMatch = false;
            if (idx - 6 >= 0) {
                isMatch = set.contains(s.substring(idx - 6, idx + 1));
                if (isMatch) {
                    idx -= 7;
                }
            }
            if (!isMatch && idx - 5 >= 0) {
                isMatch = set.contains(s.substring(idx - 5, idx + 1));
                if (isMatch) {
                    idx -= 6;
                }
            }
            if (!isMatch && idx - 4 >= 0) {
                isMatch = set.contains(s.substring(idx - 4, idx + 1));
                if (isMatch) {
                    idx -= 5;
                }
            }
            if (!isMatch) {
                System.out.println("NO");
                return;
            }
        }
        System.out.println("YES");
    }
}