# -*- coding: utf-8 -*-

def main():
    # 入力
    st = input()

    ss = ["dream", "dreamer", "erase", "eraser"]

    d_count = st.count("d")
    era_count = st.count("era")

    d_idx_ls = []
    era_idx_ls = []

    tmp_idx = 0
    for i in range(d_count):
        idx = st.index("d", tmp_idx)
        tmp_idx = idx + 1
        d_idx_ls.append(idx)

    tmp_idx = 0
    for i in range(era_count):
        idx = st.index("era", tmp_idx)
        tmp_idx = idx + 1
        era_idx_ls.append(idx)

    if d_count == 0 and era_count == 0:
        print("NO")
        return
    elif era_count == 0:
        pre_tmp_st_list = [""]
        for i in range(d_count):
            tmp_st_list = []
            for x in pre_tmp_st_list:
                tmp_st_list.append(x + "dream")
                tmp_st_list.append(x + "dreamer")
            pre_tmp_st_list = tmp_st_list

        for x in pre_tmp_st_list:
            if x == st:
                print("YES")
                return
        print("NO")
        return
    elif d_count == 0:
        pre_tmp_st_list = [""]
        for i in range(era_count):
            tmp_st_list = []
            for x in pre_tmp_st_list:
                tmp_st_list.append(x + "erase")
                tmp_st_list.append(x + "eraser")
            pre_tmp_st_list = tmp_st_list

        for x in pre_tmp_st_list:
            if x == st:
                print("YES")
                return
        print("NO")
        return
    else:
        # 2^(d_count + era_count)の候補を作成して確認
        tmp_ls_idx_d = 0
        tmp_ls_idx_era = 0
        pre_tmp_st_list = [""]
        while tmp_ls_idx_d < d_count or tmp_ls_idx_era < era_count:
            tmp_st_list = []
            # 次に追加するのがd
            if tmp_ls_idx_era == era_count:
                for x in pre_tmp_st_list:
                    a = x + "dream"
                    if st.startswith(a):
                        tmp_st_list.append(a)

                    b = x + "dreamer"
                    if st.startswith(b):
                        tmp_st_list.append(b)
                if len(tmp_st_list) == 0:
                    print("NO")
                    return
                else:
                    pre_tmp_st_list = tmp_st_list
                tmp_ls_idx_d += 1
            # 次に追加するのがera
            elif tmp_ls_idx_d == d_count:
                for x in pre_tmp_st_list:
                    a = x + "erase"
                    if st.startswith(a):
                        tmp_st_list.append(a)

                    b = x + "eraser"
                    if st.startswith(b):
                        tmp_st_list.append(b)
                if len(tmp_st_list) == 0:
                    print("NO")
                    return
                else:
                    pre_tmp_st_list = tmp_st_list
                tmp_ls_idx_era += 1
            # 次に追加するのがd
            elif d_idx_ls[tmp_ls_idx_d] < era_idx_ls[tmp_ls_idx_era]:
                for x in pre_tmp_st_list:
                    a = x + "dream"
                    if st.startswith(a):
                        tmp_st_list.append(a)

                    b = x + "dreamer"
                    if st.startswith(b):
                        tmp_st_list.append(b)
                if len(tmp_st_list) == 0:
                    print("NO")
                    return
                else:
                    pre_tmp_st_list = tmp_st_list
                tmp_ls_idx_d += 1
            # 次に追加するのがera
            else:
                for x in pre_tmp_st_list:
                    a = x + "erase"
                    if st.startswith(a):
                        tmp_st_list.append(a)

                    b = x + "eraser"
                    if st.startswith(b):
                        tmp_st_list.append(b)
                if len(tmp_st_list) == 0:
                    print("NO")
                    return
                else:
                    pre_tmp_st_list = tmp_st_list
                tmp_ls_idx_era += 1

        for x in pre_tmp_st_list:
            if x == st:
                print("YES")
                return
        print("NO")


main()


Measured memory_bytes: 4692