given = ["dreamer", "dream", "eraser", "erase"]

S = eval(input())

while len(S) > 0:

    tmp = S

    for i in given:

        if S.endswith(i):

            S = S[::-1].replace(i[::-1], "", 1)[::-1]

            if len(S) == 0:

                print("YES")

                break

    if tmp == S:

        print("NO")

        break
given = ["dreamer", "dream", "eraser", "erase"]

S = eval(input())

while len(S) > 0:

    judge = [S.endswith(i) for i in given]

    if any(judge):

        target = given[judge.index(True)]

        S = S[:-len(target)]

        if len(S) == 0:

            print("YES")

            break

    else:

        print("NO")

        break
given = ["dreamer", "dream", "eraser", "erase"]
S = eval(input())
while len(S) > 0:
    tmp = S
    for i in given:
        if S.endswith(i):
            S = S[::-1].replace(i[::-1], "", 1)[::-1]
            if len(S) == 0:
                print("YES")
                break
    if tmp == S:
        print("NO")
        break

given = ["dreamer", "dream", "eraser", "erase"]
S = eval(input())
while len(S) > 0:
    judge = [S.endswith(i) for i in given]
    if any(judge):
        target = given[judge.index(True)]
        S = S[: -len(target)]
        if len(S) == 0:
            print("YES")
            break
    else:
        print("NO")
        break

-    tmp = S -    for i in given: -        if S.endswith(i): -            S = S[::-1].replace(i[::-1], "", 1)[::-1] -            if len(S) == 0: -                print("YES") -                break -    if tmp == S: +    judge = [S.endswith(i) for i in given] +    if any(judge): +        target = given[judge.index(True)] +        S = S[: -len(target)] +        if len(S) == 0: +            print("YES") +            break +    else: