S = input().strip()

cur = 0

flag = 0

while cur<len(S):

    if S[cur:cur+11]=="dreameraser":

        cur += 11

    elif S[cur:cur+10]=="dreamerase":

        cur += 10

    elif S[cur:cur+7]=="dreamer":

        cur += 7

    elif S[cur:cur+6]=="eraser":

        cur += 6

    elif S[cur:cur+5]=="dream" or S[cur:cur+5]=="erase":

        cur += 5

    else:

        flag = 1

        break

if flag==0:

    print("YES")

else:

    print("NO")
S = input().strip()

N = len(S)

if N<5:

    print("NO")

else:

    flag = 0

    cur = N

    while cur>0:

        if cur>=7 and S[cur-7:cur]=="dreamer":

            cur -= 7

        elif cur>=6 and S[cur-6:cur]=="eraser":

            cur -= 6

        elif cur>=5 and S[cur-5:cur] in ["dream","erase"]:

            cur -= 5

        else:

            flag = 1

            break

    if flag==0:

        print("YES")

    else:

        print("NO")
S = input().strip()
cur = 0
flag = 0
while cur < len(S):
    if S[cur : cur + 11] == "dreameraser":
        cur += 11
    elif S[cur : cur + 10] == "dreamerase":
        cur += 10
    elif S[cur : cur + 7] == "dreamer":
        cur += 7
    elif S[cur : cur + 6] == "eraser":
        cur += 6
    elif S[cur : cur + 5] == "dream" or S[cur : cur + 5] == "erase":
        cur += 5
    else:
        flag = 1
        break
if flag == 0:
    print("YES")
else:
    print("NO")

S = input().strip()
N = len(S)
if N < 5:
    print("NO")
else:
    flag = 0
    cur = N
    while cur > 0:
        if cur >= 7 and S[cur - 7 : cur] == "dreamer":
            cur -= 7
        elif cur >= 6 and S[cur - 6 : cur] == "eraser":
            cur -= 6
        elif cur >= 5 and S[cur - 5 : cur] in ["dream", "erase"]:
            cur -= 5
        else:
            flag = 1
            break
    if flag == 0:
        print("YES")
    else:
        print("NO")

-cur = 0 -flag = 0 -while cur < len(S): -    if S[cur : cur + 11] == "dreameraser": -        cur += 11 -    elif S[cur : cur + 10] == "dreamerase": -        cur += 10 -    elif S[cur : cur + 7] == "dreamer": -        cur += 7 -    elif S[cur : cur + 6] == "eraser": -        cur += 6 -    elif S[cur : cur + 5] == "dream" or S[cur : cur + 5] == "erase": -        cur += 5 +N = len(S) +if N < 5: +    print("NO") +else: +    flag = 0 +    cur = N +    while cur > 0: +        if cur >= 7 and S[cur - 7 : cur] == "dreamer": +            cur -= 7 +        elif cur >= 6 and S[cur - 6 : cur] == "eraser": +            cur -= 6 +        elif cur >= 5 and S[cur - 5 : cur] in ["dream", "erase"]: +            cur -= 5 +        else: +            flag = 1 +            break +    if flag == 0: +        print("YES") -        flag = 1 -        break -if flag == 0: -    print("YES") -else: -    print("NO") +        print("NO")