import sys
from collections import deque
s = input()
queue = deque()
queue.append(0)
candidates = ['dream', 'dreamer', 'erase', 'eraser']
index = 0
while queue:
    index = queue.popleft()
    match = False
    for candidate in candidates:
        if s[index:index + len(candidate)] == candidate:
            match = True
            if index + len(candidate) == len(s):
                print('YES')
                sys.exit(0)
            queue.append(index + len(candidate))
print('NO')

c4c03380b07e2d7eb5e124ea4391d72b90dc6a59
<mask token>

<mask token>
queue.append(0)
<mask token>
while queue:
    index = queue.popleft()
    match = False
    for candidate in candidates:
        if s[index:index + len(candidate)] == candidate:
            match = True
            if index + len(candidate) == len(s):
                print('YES')
                sys.exit(0)
            queue.append(index + len(candidate))
print('NO')

<mask token>
s = input()
queue = deque()
queue.append(0)
candidates = ['dream', 'dreamer', 'erase', 'eraser']
index = 0
while queue:
    index = queue.popleft()
    match = False
    for candidate in candidates:
        if s[index:index + len(candidate)] == candidate:
            match = True
            if index + len(candidate) == len(s):
                print('YES')
                sys.exit(0)
            queue.append(index + len(candidate))
print('NO')

import sys
from collections import deque
s = input()
queue = deque()
queue.append(0)
candidates = ['dream', 'dreamer', 'erase', 'eraser']
index = 0
while queue:
    index = queue.popleft()
    match = False
    for candidate in candidates:
        if s[index:index + len(candidate)] == candidate:
            match = True
            if index + len(candidate) == len(s):
                print('YES')
                sys.exit(0)
            queue.append(index + len(candidate))
print('NO')
