S = input()[::-1]

word = ['dream'[::-1], 'dreamer'[::-1], 'erase'[::-1], 'eraser'[::-1]]

judge = [True, True, True, True]

count = 0

while any(judge):

  for i in range(len(word)):

    if S[:len(word[i])] == word[i]:

      S = S[len(word[i]):]

    else:

      count += 1

    if S == '':

      print('YES')

      exit()

    if count == 4:

      print('NO')

      exit()

  count = 0
a,b,c,d=[i[::-1] for i in ['dream','dreamer','erase','eraser']]

s,j=input()[::-1],True

while j:

  j=False

  for i in [a,b,c,d]:

    if s.startswith(i): s=s[len(i):];j=True

print(('YNEOS'[len(s)>0::2]))
S = input()[::-1]
word = ["dream"[::-1], "dreamer"[::-1], "erase"[::-1], "eraser"[::-1]]
judge = [True, True, True, True]
count = 0
while any(judge):
    for i in range(len(word)):
        if S[: len(word[i])] == word[i]:
            S = S[len(word[i]) :]
        else:
            count += 1
        if S == "":
            print("YES")
            exit()
        if count == 4:
            print("NO")
            exit()
    count = 0

a, b, c, d = [i[::-1] for i in ["dream", "dreamer", "erase", "eraser"]]
s, j = input()[::-1], True
while j:
    j = False
    for i in [a, b, c, d]:
        if s.startswith(i):
            s = s[len(i) :]
            j = True
print(("YNEOS"[len(s) > 0 :: 2]))

-S = input()[::-1] -word = ["dream"[::-1], "dreamer"[::-1], "erase"[::-1], "eraser"[::-1]] -judge = [True, True, True, True] -count = 0 -while any(judge): -    for i in range(len(word)): -        if S[: len(word[i])] == word[i]: -            S = S[len(word[i]) :] -        else: -            count += 1 -        if S == "": -            print("YES") -            exit() -        if count == 4: -            print("NO") -            exit() -    count = 0 +a, b, c, d = [i[::-1] for i in ["dream", "dreamer", "erase", "eraser"]] +s, j = input()[::-1], True +while j: +    j = False +    for i in [a, b, c, d]: +        if s.startswith(i): +            s = s[len(i) :] +            j = True +print(("YNEOS"[len(s) > 0 :: 2]))