import java.util.*;
import java.awt.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static int MOD=1000000007;
    public static void main(String[] args){
        Scanner sc = new Scanner(in);
        String s=sc.next();
        char[] d={'m','a','e','r','d'};
        char[] dr={'r','e','m','a','e','r','d'};
        char[] e={'e','s','a','r','e'};
        char[] er={'r','e','s','a','r','e'};
        int dream=0,dreamer=0,erase=0,eraser=0,temp;
        int n=s.length(),count=0;
        for (int i = 0; i < n; i++) {
            temp=dream+erase+dreamer+eraser;
            char p=s.charAt(n-i-1);
            if(p==d[dream])dream++;
            if(p==dr[dreamer])dreamer++;
            if(p==e[erase])erase++;
            if(p==er[eraser])eraser++;
            count++;
            if(temp==dream+dreamer+erase+eraser){
                out.println("NO");
                exit(0);
            }
            if(count!=max(max(dream,dreamer),max(erase,eraser))){
                out.println("NO");
                exit(0);
            }
            if(dreamer==7||dream==5||erase==5||eraser==6){
                dream=dreamer=erase=eraser=count=0;
            }
        }
        out.println("YES");
    }
} import java.util.*; util.* java import java.awt.*; awt.* java import static java.lang.System.*; import static java.lang.System.*; import static java.lang.System.*; import static java.lang.Math.*; import static java.lang.Math.*; import static java.lang.Math.*; public class Main {
    public static int MOD=1000000007;
    public static void main(String[] args){
        Scanner sc = new Scanner(in);
        String s=sc.next();
        char[] d={'m','a','e','r','d'};
        char[] dr={'r','e','m','a','e','r','d'};
        char[] e={'e','s','a','r','e'};
        char[] er={'r','e','s','a','r','e'};
        int dream=0,dreamer=0,erase=0,eraser=0,temp;
        int n=s.length(),count=0;
        for (int i = 0; i < n; i++) {
            temp=dream+erase+dreamer+eraser;
            char p=s.charAt(n-i-1);
            if(p==d[dream])dream++;
            if(p==dr[dreamer])dreamer++;
            if(p==e[erase])erase++;
            if(p==er[eraser])eraser++;
            count++;
            if(temp==dream+dreamer+erase+eraser){
                out.println("NO");
                exit(0);
            }
            if(count!=max(max(dream,dreamer),max(erase,eraser))){
                out.println("NO");
                exit(0);
            }
            if(dreamer==7||dream==5||erase==5||eraser==6){
                dream=dreamer=erase=eraser=count=0;
            }
        }
        out.println("YES");
    }
} Main public static int MOD=1000000007; MOD 1000000007 public static void main(String[] args){
        Scanner sc = new Scanner(in);
        String s=sc.next();
        char[] d={'m','a','e','r','d'};
        char[] dr={'r','e','m','a','e','r','d'};
        char[] e={'e','s','a','r','e'};
        char[] er={'r','e','s','a','r','e'};
        int dream=0,dreamer=0,erase=0,eraser=0,temp;
        int n=s.length(),count=0;
        for (int i = 0; i < n; i++) {
            temp=dream+erase+dreamer+eraser;
            char p=s.charAt(n-i-1);
            if(p==d[dream])dream++;
            if(p==dr[dreamer])dreamer++;
            if(p==e[erase])erase++;
            if(p==er[eraser])eraser++;
            count++;
            if(temp==dream+dreamer+erase+eraser){
                out.println("NO");
                exit(0);
            }
            if(count!=max(max(dream,dreamer),max(erase,eraser))){
                out.println("NO");
                exit(0);
            }
            if(dreamer==7||dream==5||erase==5||eraser==6){
                dream=dreamer=erase=eraser=count=0;
            }
        }
        out.println("YES");
    } main {
        Scanner sc = new Scanner(in);
        String s=sc.next();
        char[] d={'m','a','e','r','d'};
        char[] dr={'r','e','m','a','e','r','d'};
        char[] e={'e','s','a','r','e'};
        char[] er={'r','e','s','a','r','e'};
        int dream=0,dreamer=0,erase=0,eraser=0,temp;
        int n=s.length(),count=0;
        for (int i = 0; i < n; i++) {
            temp=dream+erase+dreamer+eraser;
            char p=s.charAt(n-i-1);
            if(p==d[dream])dream++;
            if(p==dr[dreamer])dreamer++;
            if(p==e[erase])erase++;
            if(p==er[eraser])eraser++;
            count++;
            if(temp==dream+dreamer+erase+eraser){
                out.println("NO");
                exit(0);
            }
            if(count!=max(max(dream,dreamer),max(erase,eraser))){
                out.println("NO");
                exit(0);
            }
            if(dreamer==7||dream==5||erase==5||eraser==6){
                dream=dreamer=erase=eraser=count=0;
            }
        }
        out.println("YES");
    } Scanner sc = new Scanner(in); sc new Scanner(in) String s=sc.next(); s sc.next() sc.next sc char[] d={'m','a','e','r','d'}; d {'m','a','e','r','d'} 'm' 'a' 'e' 'r' 'd' char[] dr={'r','e','m','a','e','r','d'}; dr {'r','e','m','a','e','r','d'} 'r' 'e' 'm' 'a' 'e' 'r' 'd' char[] e={'e','s','a','r','e'}; e {'e','s','a','r','e'} 'e' 's' 'a' 'r' 'e' char[] er={'r','e','s','a','r','e'}; er {'r','e','s','a','r','e'} 'r' 'e' 's' 'a' 'r' 'e' int dream=0 dream 0 dreamer=0 dreamer 0 erase=0 erase 0 eraser=0 eraser 0 temp; temp int n=s.length() n s.length() s.length s count=0; count 0 for (int i = 0; i < n; i++) {
            temp=dream+erase+dreamer+eraser;
            char p=s.charAt(n-i-1);
            if(p==d[dream])dream++;
            if(p==dr[dreamer])dreamer++;
            if(p==e[erase])erase++;
            if(p==er[eraser])eraser++;
            count++;
            if(temp==dream+dreamer+erase+eraser){
                out.println("NO");
                exit(0);
            }
            if(count!=max(max(dream,dreamer),max(erase,eraser))){
                out.println("NO");
                exit(0);
            }
            if(dreamer==7||dream==5||erase==5||eraser==6){
                dream=dreamer=erase=eraser=count=0;
            }
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            temp=dream+erase+dreamer+eraser;
            char p=s.charAt(n-i-1);
            if(p==d[dream])dream++;
            if(p==dr[dreamer])dreamer++;
            if(p==e[erase])erase++;
            if(p==er[eraser])eraser++;
            count++;
            if(temp==dream+dreamer+erase+eraser){
                out.println("NO");
                exit(0);
            }
            if(count!=max(max(dream,dreamer),max(erase,eraser))){
                out.println("NO");
                exit(0);
            }
            if(dreamer==7||dream==5||erase==5||eraser==6){
                dream=dreamer=erase=eraser=count=0;
            }
        } {
            temp=dream+erase+dreamer+eraser;
            char p=s.charAt(n-i-1);
            if(p==d[dream])dream++;
            if(p==dr[dreamer])dreamer++;
            if(p==e[erase])erase++;
            if(p==er[eraser])eraser++;
            count++;
            if(temp==dream+dreamer+erase+eraser){
                out.println("NO");
                exit(0);
            }
            if(count!=max(max(dream,dreamer),max(erase,eraser))){
                out.println("NO");
                exit(0);
            }
            if(dreamer==7||dream==5||erase==5||eraser==6){
                dream=dreamer=erase=eraser=count=0;
            }
        } temp=dream+erase+dreamer+eraser temp dream+erase+dreamer+eraser dreamer dream+erase+dreamer+eraser dream erase dreamer eraser char p=s.charAt(n-i-1); p s.charAt(n-i-1) s.charAt s n-i-1 n-i-1 n i 1 if(p==d[dream])dream++; p==d[dream] p d[dream] d dream dream++ dream if(p==dr[dreamer])dreamer++; p==dr[dreamer] p dr[dreamer] dr dreamer dreamer++ dreamer if(p==e[erase])erase++; p==e[erase] p e[erase] e erase erase++ erase if(p==er[eraser])eraser++; p==er[eraser] p er[eraser] er eraser eraser++ eraser count++ count if(temp==dream+dreamer+erase+eraser){
                out.println("NO");
                exit(0);
            } temp==dream+dreamer+erase+eraser temp dream+dreamer+erase+eraser erase dream+dreamer+erase+eraser dream dreamer erase eraser {
                out.println("NO");
                exit(0);
            } out.println("NO") out.println out "NO" exit(0) exit 0 if(count!=max(max(dream,dreamer),max(erase,eraser))){
                out.println("NO");
                exit(0);
            } count!=max(max(dream,dreamer),max(erase,eraser)) count max(max(dream,dreamer),max(erase,eraser)) max max(dream,dreamer) max dream dreamer max(erase,eraser) max erase eraser {
                out.println("NO");
                exit(0);
            } out.println("NO") out.println out "NO" exit(0) exit 0 if(dreamer==7||dream==5||erase==5||eraser==6){
                dream=dreamer=erase=eraser=count=0;
            } dreamer==7||dream==5||erase==5||eraser==6 erase==5 dreamer==7||dream==5||erase==5||eraser==6 dreamer==7 dreamer 7 dream==5 dream 5 erase==5 erase 5 eraser==6 eraser 6 {
                dream=dreamer=erase=eraser=count=0;
            } dream=dreamer=erase=eraser=count=0 dream dreamer=erase=eraser=count=0 dreamer erase=eraser=count=0 erase eraser=count=0 eraser count=0 count 0 out.println("YES") out.println out "YES" String[] args args public class Main {
    public static int MOD=1000000007;
    public static void main(String[] args){
        Scanner sc = new Scanner(in);
        String s=sc.next();
        char[] d={'m','a','e','r','d'};
        char[] dr={'r','e','m','a','e','r','d'};
        char[] e={'e','s','a','r','e'};
        char[] er={'r','e','s','a','r','e'};
        int dream=0,dreamer=0,erase=0,eraser=0,temp;
        int n=s.length(),count=0;
        for (int i = 0; i < n; i++) {
            temp=dream+erase+dreamer+eraser;
            char p=s.charAt(n-i-1);
            if(p==d[dream])dream++;
            if(p==dr[dreamer])dreamer++;
            if(p==e[erase])erase++;
            if(p==er[eraser])eraser++;
            count++;
            if(temp==dream+dreamer+erase+eraser){
                out.println("NO");
                exit(0);
            }
            if(count!=max(max(dream,dreamer),max(erase,eraser))){
                out.println("NO");
                exit(0);
            }
            if(dreamer==7||dream==5||erase==5||eraser==6){
                dream=dreamer=erase=eraser=count=0;
            }
        }
        out.println("YES");
    }
} public class Main {
    public static int MOD=1000000007;
    public static void main(String[] args){
        Scanner sc = new Scanner(in);
        String s=sc.next();
        char[] d={'m','a','e','r','d'};
        char[] dr={'r','e','m','a','e','r','d'};
        char[] e={'e','s','a','r','e'};
        char[] er={'r','e','s','a','r','e'};
        int dream=0,dreamer=0,erase=0,eraser=0,temp;
        int n=s.length(),count=0;
        for (int i = 0; i < n; i++) {
            temp=dream+erase+dreamer+eraser;
            char p=s.charAt(n-i-1);
            if(p==d[dream])dream++;
            if(p==dr[dreamer])dreamer++;
            if(p==e[erase])erase++;
            if(p==er[eraser])eraser++;
            count++;
            if(temp==dream+dreamer+erase+eraser){
                out.println("NO");
                exit(0);
            }
            if(count!=max(max(dream,dreamer),max(erase,eraser))){
                out.println("NO");
                exit(0);
            }
            if(dreamer==7||dream==5||erase==5||eraser==6){
                dream=dreamer=erase=eraser=count=0;
            }
        }
        out.println("YES");
    }
} Main
import java.util.*;
import java.awt.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static int MOD=1000000007;
    public static void main(String[] args){
        Scanner sc = new Scanner(in);
        String s=sc.next();
        char[] d={'m','a','e','r','d'};
        char[] dr={'r','e','m','a','e','r','d'};
        char[] e={'e','s','a','r','e'};
        char[] er={'r','e','s','a','r','e'};
        int dream=0,dreamer=0,erase=0,eraser=0,temp;
        int n=s.length(),count=0;
        for (int i = 0; i < n; i++) {
            temp=dream+erase+dreamer+eraser;
            char p=s.charAt(n-i-1);
            if(p==d[dream])dream++;
            if(p==dr[dreamer])dreamer++;
            if(p==e[erase])erase++;
            if(p==er[eraser])eraser++;
            count++;
            if(temp==dream+dreamer+erase+eraser){
                out.println("NO");
                exit(0);
            }
            if(count!=max(max(dream,dreamer),max(erase,eraser))){
                out.println("NO");
                exit(0);
            }
            if(dreamer==7||dream==5||erase==5||eraser==6){
                dream=dreamer=erase=eraser=count=0;
            }
        }
        out.println("YES");
    }
}