from collections import deque



S = eval(input())

l = len(S)



a = list(map(list,['dream','dreamer','erase','eraser']))

q = deque()

q.append(["",0])



while len(q):

    b,i = q.pop()

    if i == l:

        print('YES')

        exit()

    x = 0

    f = True

    for B in b:

        if i+x >= l or S[i+x] != B:

            f = False

        x += 1

    if f:

        for A in a:

            q.append([A,i+x])



print('NO')

from collections import deque



S = list(eval(input()))

S.reverse()

l = len(S)



def rev(x):

    x = list(x)

    x.reverse()

    return x



a = list(map(rev,['dream','dreamer','erase','eraser']))

q = deque()

q.append(["",0])



while len(q):

    b,i = q.pop()

    if i == l:

        print('YES')

        exit()

    x = 0

    f = True

    for B in b:

        if i+x >= l or S[i+x] != B:

            f = False

        x += 1

    if f:

        for A in a:

            q.append([A,i+x])



print('NO')

from collections import deque

S = eval(input())
l = len(S)
a = list(map(list, ["dream", "dreamer", "erase", "eraser"]))
q = deque()
q.append(["", 0])
while len(q):
    b, i = q.pop()
    if i == l:
        print("YES")
        exit()
    x = 0
    f = True
    for B in b:
        if i + x >= l or S[i + x] != B:
            f = False
        x += 1
    if f:
        for A in a:
            q.append([A, i + x])
print("NO")

from collections import deque

S = list(eval(input()))
S.reverse()
l = len(S)


def rev(x):
    x = list(x)
    x.reverse()
    return x


a = list(map(rev, ["dream", "dreamer", "erase", "eraser"]))
q = deque()
q.append(["", 0])
while len(q):
    b, i = q.pop()
    if i == l:
        print("YES")
        exit()
    x = 0
    f = True
    for B in b:
        if i + x >= l or S[i + x] != B:
            f = False
        x += 1
    if f:
        for A in a:
            q.append([A, i + x])
print("NO")

-S = eval(input()) +S = list(eval(input())) +S.reverse() -a = list(map(list, ["dream", "dreamer", "erase", "eraser"])) + + +def rev(x): +    x = list(x) +    x.reverse() +    return x + + +a = list(map(rev, ["dream", "dreamer", "erase", "eraser"]))