s = eval(input())



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



#print(s[-5:],s[-6:],s[-7:])



while True:

    if s[-5:] in li:

        s = s[0:-5]

    elif s[-6:] in li:

        s = s[0:-6]

    elif s[-7:] in li:

        s = s[0:-7]

    else:

        print('NO')

        exit()

    if s=='':

        break

print('YES')
S = eval(input())

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

fl = True

while fl:

    if S[-5:] in str_list:

        S = S[0:-5]

    elif S[-6:] in str_list:

        S = S[0:-6]

    elif S[-7:] in str_list:

        S = S[0:-7]

    elif S=="":

        fl = False

    else:

        print('NO')

        exit()

print('YES')
s = eval(input())
li = ["dream", "dreamer", "erase", "eraser"]
# print(s[-5:],s[-6:],s[-7:])
while True:
    if s[-5:] in li:
        s = s[0:-5]
    elif s[-6:] in li:
        s = s[0:-6]
    elif s[-7:] in li:
        s = s[0:-7]
    else:
        print("NO")
        exit()
    if s == "":
        break
print("YES")

S = eval(input())
str_list = ["dream", "dreamer", "erase", "eraser"]
fl = True
while fl:
    if S[-5:] in str_list:
        S = S[0:-5]
    elif S[-6:] in str_list:
        S = S[0:-6]
    elif S[-7:] in str_list:
        S = S[0:-7]
    elif S == "":
        fl = False
    else:
        print("NO")
        exit()
print("YES")

-s = eval(input()) -li = ["dream", "dreamer", "erase", "eraser"] -# print(s[-5:],s[-6:],s[-7:]) -while True: -    if s[-5:] in li: -        s = s[0:-5] -    elif s[-6:] in li: -        s = s[0:-6] -    elif s[-7:] in li: -        s = s[0:-7] +S = eval(input()) +str_list = ["dream", "dreamer", "erase", "eraser"] +fl = True +while fl: +    if S[-5:] in str_list: +        S = S[0:-5] +    elif S[-6:] in str_list: +        S = S[0:-6] +    elif S[-7:] in str_list: +        S = S[0:-7] +    elif S == "": +        fl = False -    if s == "": -        break