You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times:    * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`.
s = input()

bool = [False]

def hantei(s):
    # print(s)
    if s=='':
        bool[0]=True
        return

    if s.count('dream')>=1:
        r=s.replace('dream','')
        hantei(r)

    if s.count('dreamer')>=1:
        r=s.replace('dreamer','')
        hantei(r)

    if s.count('erase')>=1:
        r=s.replace('erase','')
        hantei(r)

    if s.count('eraser')>=1:
        r=s.replace('eraser','')
        hantei(r)
    return

hantei(s)
        

if bool[0]==True:
    print('Yes')

if bool[0]==False:
    print('No')


s = input()

bool = [False]

def hantei(s):
    # print(s)
    if s=='':
        bool[0]=True
        return

    if s.count('dream')>=1:
        r=s.replace('dream','')
        hantei(r)

    if s.count('dreamer')>=1:
        r=s.replace('dreamer','')
        hantei(r)

    if s.count('erase')>=1:
        r=s.replace('erase','')
        hantei(r)

    if s.count('eraser')>=1:
        r=s.replace('eraser','')
        hantei(r)
    return

hantei(s)
        

if bool[0]==True:
    print('YES')

if bool[0]==False:
    print('NO')

