ar = list(eval(input()))

while True:

    a = len(ar)

    if a == 0:

        print("YES")

        break

    if "".join(ar[a-5:a]) == "dream" or "".join(ar[a-5:a]) == "erase":

        del ar[a-5:a]

    elif "".join(ar[a-6:a]) == "eraser":

        del ar[a-6:a]

    elif "".join(ar[a-7:a]) == "dreamer":

        del ar[a-7:a]

    else:

        print("NO")

        break
ar = list(eval(input()))

l = len(ar)

if l < 5:

    print('NO')

else:

    while True:

        if l == 0:

            print("YES")

            exit()

        if "".join(ar[l-5:l]) == 'dream' or "".join(ar[l-5:l]) == 'erase':

            l -= 5

        elif "".join(ar[l-6:l]) == 'eraser':

            l -= 6

        elif "".join(ar[l-7:l]) == 'dreamer':

            l -= 7

        else:

            print("NO")

            exit()

ar = list(eval(input()))
while True:
    a = len(ar)
    if a == 0:
        print("YES")
        break
    if "".join(ar[a - 5 : a]) == "dream" or "".join(ar[a - 5 : a]) == "erase":
        del ar[a - 5 : a]
    elif "".join(ar[a - 6 : a]) == "eraser":
        del ar[a - 6 : a]
    elif "".join(ar[a - 7 : a]) == "dreamer":
        del ar[a - 7 : a]
    else:
        print("NO")
        break

ar = list(eval(input()))
l = len(ar)
if l < 5:
    print("NO")
else:
    while True:
        if l == 0:
            print("YES")
            exit()
        if "".join(ar[l - 5 : l]) == "dream" or "".join(ar[l - 5 : l]) == "erase":
            l -= 5
        elif "".join(ar[l - 6 : l]) == "eraser":
            l -= 6
        elif "".join(ar[l - 7 : l]) == "dreamer":
            l -= 7
        else:
            print("NO")
            exit()

-while True: -    a = len(ar) -    if a == 0: -        print("YES") -        break -    if "".join(ar[a - 5 : a]) == "dream" or "".join(ar[a - 5 : a]) == "erase": -        del ar[a - 5 : a] -    elif "".join(ar[a - 6 : a]) == "eraser": -        del ar[a - 6 : a] -    elif "".join(ar[a - 7 : a]) == "dreamer": -        del ar[a - 7 : a] -    else: -        print("NO") -        break +l = len(ar) +if l < 5: +    print("NO") +else: +    while True: +        if l == 0: +            print("YES") +            exit() +        if "".join(ar[l - 5 : l]) == "dream" or "".join(ar[l - 5 : l]) == "erase": +            l -= 5 +        elif "".join(ar[l - 6 : l]) == "eraser": +            l -= 6 +        elif "".join(ar[l - 7 : l]) == "dreamer": +            l -= 7 +        else: +            print("NO") +            exit()