S = input()[::-1]

W = []

for w in ['dreamer', 'eraser', 'erase', 'dream']:

    W.append(w[::-1])

while 1:

    flg = False

    for w in W:

        if S.startswith(w):

            S = S[len(w):]

            flg = True



    if not flg:

        print('NO')

        exit()

    if not S:

        break



print('YES')

S = input()[::-1]

W = []

for w in ['dreamer', 'eraser', 'erase', 'dream']:

    W.append(w[::-1])

idx = 0

while 1:

    flg = False

    for w in W:

        if S.startswith(w, idx):

            idx += len(w)

            flg = True



    if not flg:

        print('NO')

        exit()

    if len(S) <= idx:

        break



print('YES')

S = input()[::-1]
W = []
for w in ["dreamer", "eraser", "erase", "dream"]:
    W.append(w[::-1])
while 1:
    flg = False
    for w in W:
        if S.startswith(w):
            S = S[len(w) :]
            flg = True
    if not flg:
        print("NO")
        exit()
    if not S:
        break
print("YES")

S = input()[::-1]
W = []
for w in ["dreamer", "eraser", "erase", "dream"]:
    W.append(w[::-1])
idx = 0
while 1:
    flg = False
    for w in W:
        if S.startswith(w, idx):
            idx += len(w)
            flg = True
    if not flg:
        print("NO")
        exit()
    if len(S) <= idx:
        break
print("YES")

+idx = 0 -        if S.startswith(w): -            S = S[len(w) :] +        if S.startswith(w, idx): +            idx += len(w) -    if not S: +    if len(S) <= idx: