S = eval(input())

S_r = S[::-1]

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

dire_r = [0]*4

for i in range(4):

    tmp = dire[i]

    dire_r[i] = tmp[::-1]

ind = 0



excep = 0



while ind  <len(S_r):

    if excep == 1:

        break

    flag2= 0

    for j in range(4):

        if flag2 ==0:

            case = 0

            for k in range(len(dire_r[j])):

                tmp = dire_r[j]



                if ind + k < len(S_r) and case == 0:

                #    print(j)

            #        print('S:'+S_r[ind+k])

            #        print('dire:'+tmp[k])

                    if S_r[ind+k] != tmp[k]:

                        flag = 0

                        case = 1

                        if j == 3:

                            excep = 1



                    elif k== len(dire_r[j])  -1:

                        ind = ind + len(dire_r[j])

                        flag = 1

                        case = 1

                        flag2 = 1





if flag == 1:

    print('YES')

else:

    print('NO')

S = eval(input())



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



DP = [0] * 100000



DP[0] = 1



for s in range(len(S)):

    if DP[s] != 1:

        continue



    for i in range(4):

        tmp = S[s: s+len(dire[i])]

        if tmp == dire[i]:

            DP[s + len(dire[i])] = 1



if DP[len(S)] == 1:

    print('YES')

else:

    print('NO')

S = eval(input())
S_r = S[::-1]
dire = ["dream", "dreamer", "erase", "eraser"]
dire_r = [0] * 4
for i in range(4):
    tmp = dire[i]
    dire_r[i] = tmp[::-1]
ind = 0
excep = 0
while ind < len(S_r):
    if excep == 1:
        break
    flag2 = 0
    for j in range(4):
        if flag2 == 0:
            case = 0
            for k in range(len(dire_r[j])):
                tmp = dire_r[j]
                if ind + k < len(S_r) and case == 0:
                    #    print(j)
                    #        print('S:'+S_r[ind+k])
                    #        print('dire:'+tmp[k])
                    if S_r[ind + k] != tmp[k]:
                        flag = 0
                        case = 1
                        if j == 3:
                            excep = 1
                    elif k == len(dire_r[j]) - 1:
                        ind = ind + len(dire_r[j])
                        flag = 1
                        case = 1
                        flag2 = 1
if flag == 1:
    print("YES")
else:
    print("NO")

S = eval(input())
dire = ["dream", "dreamer", "erase", "eraser"]
DP = [0] * 100000
DP[0] = 1
for s in range(len(S)):
    if DP[s] != 1:
        continue
    for i in range(4):
        tmp = S[s : s + len(dire[i])]
        if tmp == dire[i]:
            DP[s + len(dire[i])] = 1
if DP[len(S)] == 1:
    print("YES")
else:
    print("NO")

-S_r = S[::-1] -dire_r = [0] * 4 -for i in range(4): -    tmp = dire[i] -    dire_r[i] = tmp[::-1] -ind = 0 -excep = 0 -while ind < len(S_r): -    if excep == 1: -        break -    flag2 = 0 -    for j in range(4): -        if flag2 == 0: -            case = 0 -            for k in range(len(dire_r[j])): -                tmp = dire_r[j] -                if ind + k < len(S_r) and case == 0: -                    #    print(j) -                    #        print('S:'+S_r[ind+k]) -                    #        print('dire:'+tmp[k]) -                    if S_r[ind + k] != tmp[k]: -                        flag = 0 -                        case = 1 -                        if j == 3: -                            excep = 1 -                    elif k == len(dire_r[j]) - 1: -                        ind = ind + len(dire_r[j]) -                        flag = 1 -                        case = 1 -                        flag2 = 1 -if flag == 1: +DP = [0] * 100000 +DP[0] = 1 +for s in range(len(S)): +    if DP[s] != 1: +        continue +    for i in range(4): +        tmp = S[s : s + len(dire[i])] +        if tmp == dire[i]: +            DP[s + len(dire[i])] = 1 +if DP[len(S)] == 1: