s=input()[::-1]

d=['maerd','remaerd','esare','resare']

while s:

    for i in range(4):

        if s.startswith(d[i]):

            s=s[len(d[i]):]

            break

    else:

        print('NO')

        exit()

print('YES')

s=eval(input())

d=['dream','dreamer','erase','eraser']

while s:

    for m in d:

        if s.endswith(m):

            s=s[:-len(m)]

            break

    else:

        print('NO')

        exit()

print('YES')

s = input()[::-1]
d = ["maerd", "remaerd", "esare", "resare"]
while s:
    for i in range(4):
        if s.startswith(d[i]):
            s = s[len(d[i]) :]
            break
    else:
        print("NO")
        exit()
print("YES")

s = eval(input())
d = ["dream", "dreamer", "erase", "eraser"]
while s:
    for m in d:
        if s.endswith(m):
            s = s[: -len(m)]
            break
    else:
        print("NO")
        exit()
print("YES")

-s = input()[::-1] -d = ["maerd", "remaerd", "esare", "resare"] +s = eval(input()) +d = ["dream", "dreamer", "erase", "eraser"] -    for i in range(4): -        if s.startswith(d[i]): -            s = s[len(d[i]) :] +    for m in d: +        if s.endswith(m): +            s = s[: -len(m)]