// c lib
#include <cstdio>
#include <cstdlib>
#include <cmath>

// container
#include <vector>
#include <string>
#include <map>
#include <list>
#include <queue>

// Convenience
#include <algorithm>
#include <functional>

// IO
#include <iostream>

using namespace std;

typedef enum {
    wordhead,
    dream_m,
    dream_a,
    dream_e,
    dream_r,
    erase_e,
    erase_s,
    erase_a,
    erase_r,
    er_r,
    er_e,
}  State;

int main() {
    string s;
    cin >> s;

    State state = wordhead;
    auto wordCount = 0;
    for (auto itr = s.rbegin(); itr != s.rend(); itr++) {
        switch (state)
        {
        case wordhead:
            switch (*itr)
            {
            case 'm':
                state = dream_m;
                break;
            case 'e':
                state = erase_e;
                break;
            case 'r':
                state = er_r;
                break;
            default:
                cout << "NO" << endl;
                return 0;
            }
            break;
        case dream_m:
            if (*itr == 'a') {
                state = dream_a;
            } 
            else {
                cout << "NO" << endl;
                return 0;
            }
            break;
        case dream_a:
            if (*itr == 'e') {
                state = dream_e;
            } 
            else {
                cout << "NO" << endl;
                return 0;
            }
            break;
        case dream_e:
            if (*itr == 'r') {
                state = dream_r;
            } 
            else {
                cout << "NO" << endl;
                return 0;
            }
            break;
        case dream_r:
            if (*itr == 'd') {
                state = wordhead;
            } 
            else {
                cout << "NO" << endl;
                return 0;
            }
            break;
        case erase_e:
            if (*itr == 's') {
                state = erase_s;
            } 
            else {
                cout << "NO" << endl;
                return 0;
            }
            break;
        case erase_s:
            if (*itr == 'a') {
                state = erase_a;
            } 
            else {
                cout << "NO" << endl;
                return 0;
            }
            break;
        case erase_a:
            if (*itr == 'r') {
                state = erase_r;
            } 
            else {
                cout << "NO" << endl;
                return 0;
            }
            break;
        case erase_r:
            if (*itr == 'e') {
                state = wordhead;
            } 
            else {
                cout << "NO" << endl;
                return 0;
            }
            break;
        case er_r:
            if (*itr == 'e') {
                state = er_e;
            } 
            else {
                cout << "NO" << endl;
                return 0;
            }
            break;
        case er_e:
            switch (*itr)
            {
            case 'm':
                state = dream_m;
                break;
            case 's':
                state = erase_s;
                break;
            default:
                cout << "NO" << endl;
                return 0;
            }
            break;
        }
    }

    cout << "YES" << endl;
}

Measured memory_bytes: 512