peterverebics/CodeNet_Python_118 huggingface dataset:
s = input()
ans = "YES"
while s != "":
    if s[len(s) - 5:] == "dream" or s[len(s) - 5:] == "erase":
        s = s[:len(s) - 5]
    elif s[len(s) - 6:] == "eraser":
        s = s[:len(s) - 6]
    elif s[len(s) - 7] == "dreamer":
        s = s[:len(s) - 7]
    else:
        ans = "NO"
        break
print(ans)
# -*- coding: utf-8 -*-

S = input()

S = S.replace("eraser", "")
S = S.replace("erase", "")
S = S.replace("dreamer", "")
S = S.replace("dream", "").strip()




if len(S) ==0:
    print("NO")
else:
    print("YES")
s = str(input())
a = ['dream', 'dreamer', 'erase', 'eraser']

f = True
while f:
    os = s
    for i in a:
        if s.endswith(i):
            s = s[:-len(i)]
            if len(s) == 0:
                print("YES")
                f = False
    if len(os) == len(s):
        print("No")
        f = False
dr ="dream" 
dre = "dreamer" 
er ="erase" 
ere = "eraser" 
a = input()
ret = "YES"
while len(a) != 0:
    if (a.endswith(dr) or a.endswith(er)):
        a = a[:len(a)-5]
    elif(a.endswith(dre) or a.endswith(ere)):
        a = a[:len(a)-7]
    else:
        ret = "NO"
        break
        
print(ret)
S = input()
results = True
while results:
    for key_word in ["erase", "eraser", "dream", "dreamer"]:
        if S.endswith(key_word):
            S = S.rstrip(key_word)
            continue
    if S == '':
        print("YES")
        results = False
        break
    else:
        print("NO")
        results = False
        break
S = input()
Mozi = ["dreamer","eraser","dream","erase"]

for i in Mozi:
    T = S.strip(i)
    S = T
if not S:
    print("Yes")
else:
    print("No")
words = ['dream','dreamer', 'erase', 'eraser']
s = raw_input()
dp = [False for _ in range(len(s))]
i = 0
for j in range(len(s)):
	dp[j] = any([(dp[j - len(w) - 1] if j - len(w) -1 >= 0 else True) and s[j- len(w):j+1] == w  for w in words])

print 'YES' if dp[-1] else 'NO'
def main():
    import sys

    def input(): return sys.stdin.readline().rstrip()

    s = input()
    word = ['eraser', 'erase', 'dreamer', 'dream']
    for x in word:
        s = s.replace(x, '')
    if s == '':
        print('Yes')
    else:
        print('No')
        
        
        
            
        
    
    
if __name__ == '__main__':
    main()
s=input()[::-1]
words = {"dream", "dreamer", "erase", "eraser"}
for i in words:
    s = s.replace(i[::-1],'')
print("NO"if len(s)else "YES")
S = input()

if S.replace("dream","").replace("dreamer","").replace("erase","").replace("eraser",""):
  print("NO")
else:
  print("YES")
s = input()[::-1]
ls = ['dream', 'dreamer', 'erase', 'eraser']
ls = [ls[i][::-1] for i in range(4)]

ans = 'YES'
i = 0
while i < len(s):
    ng = 1
    for j in range(4):
        if s[i:i+len(ls[j])] == ls[j]:
            i += len(ls[j])
            ng = 0
    if ng:
        ans = 'No'
        break
print(ans)
# 動的計画法(DP)
s=input()
words = {"dream", "dreamer", "erase", "eraser"}

dp = dict()
for i in range(0, len(s)):
    for word in words:
        if s[i:i+len(word)] == word:
            dp[i+len(word)] = 1

print("YES" if dp.get(len(s)) else "NO")
words = ['dream','dreamer', 'erase', 'eraser']
s = raw_input()

dp = [False for _ in range(len(s))]
i = 0
for j in range(len(s)):
	dp[j] = any([s[j- len(w):j+1] == w for w in words])

print 'YES' if dp[-1] else 'NO'
S = input()
strs = list(reversed(S))
rev_S = ''.join(strs)
rev_S.replace('maerd', '')
rev_S.replace('remaerd', '')
rev_S.replace('esare', '')
rev_S.replace('resare', '')
if rev_S.replace == '':
  print('YES')
else:
  print('NO')
S = input()
results = True
while results:
    for key_word in ["erase", "eraser", "dream", "dreamer"]:
        if S.endswith(key_word):
            S = S[:-len(key_word)]
            continue
    if S == '':
        print("YES")
        results = False
        break
    else:
        print("NO")
        results = False
        break
s=input()[::-1]
i=0
while i<len(s):
    if i+5<=len(s) and s[i:i+5]=='rsare':
        i+=5
    elif i+5<=len(s) and s[i:i+5]=='maerd':
        i+=5
    elif i+6<=len(s) and s[i:i+6]=='resare':
        i+=6
    elif i+7<=len(s) and s[i:i+7]=='remaerd':
        i+=7
    elif i<len(s):
        print('NO')
        exit()
print('YES')
S = input()

while S:
    if S[-5:] == "dream" or S[-5:] == "erase":
        S = S[:-5]
    elif S[-6:] == "dreamer" or S[-6:] == "eraser":
        S = S[:-6]
    else:
        break


if S:
    print("NO")
else:
    print("YES")
S = input()
words = ("dream", "dreamer", "erase", "eraser")

while S:
    for word in words:
        if S.endswith(word):
            S = S[: -len(word)]
    else:
        break
print("NO") if S else print("YES")
s = input()
str_list = ['eraser', 'erase', 'dream', 'dreamer']
for i in range(len(str_list)):
    if len(str_list[i])==7 and s[-7:]=='dreamer':
        s = s[:-7]
    elif len(str_list[i])==6 and s[-6:]=='eraser':
        s = s[:-6]
    elif s[-5:]=='erase' or s[-5:]=='dream':
        s = s[:-5]
        
if s=='':
    print('YES')
else:
    print('NO')
import re
sin = input()
match = re.match(r"^.*(dream|dreamer|erase|eraser)$",sin)
print("YES" if match else "NO")
s = input()

while True:
  if len(s) == 0:
    print("YES")
    break
  elif len(s) < 5:
    print("NO")
    break
  else:
    if s[:5] == "dream":
      s = s.replace("dream", "", 1)
    elif s[:6] == "eraser":
      s = s.replace("eraser", "", 1)
    elif s[:7] == "dreamer" :
      s = s.replace("dreamer", "", 1)
    elif s[:5] == "erase":
      s = s.replace("erase", "", 1)
    else:
      print("NO")
      break
S = input()
 
# 前から順に消すと詰む
# 後ろから順に消すと一意に定まる
while True:
  if S[-5:] == 'erase': S = S[:-5]
  else:
    if S[-6:] == 'eraser': S = S[:-6]
    else:
      if S[-5:] == 'dream': S = S[:-5]
      else:
        if S[-7:] == 'dreamer': S = S[:-7]
        else: break

if len(S) == 0: print('Yes')
else: print('No')
S = input()
while True :
  if S[-5:] == "dream":
    S = S.replace("dream","")
  elif S[-6:] == "eraser":
    S = S.replace("eraser","")
  elif S[-7:] == "dreamer":
    S = S.replace("dreamer","")
  elif S[-5:] == "erase":
    S = S.replace("erase","")
  elif len(S) == 0:
    print("YES")
    break
  else:
    print("NO")
    break
S = input()[::-1]
word = ['dream'[::-1], 'dreamer'[::-1], 'erase'[::-1], 'eraser'[::-1]]
judge = [True, True, True, True]
while any(judge):
  for i in range(len(word)):
    if S[:len(word[i])] == word[i]:
      S = S[len(word[i]):]
    else:
      judge[i] = False
    if S == '':
      print('YES')
      exit()
print('NO')
s = input().replace('dreamer', '').replace('eraser', '').replace('dream', '').replace('erase', '')
print('YES' if s=='' else 'NO')
S = input()
T = ['dream', 'dreamer', 'erase', 'eraser']


def reverse(t):
    return t[::-1]


RT = [reverse(t) for t in T]
RS = reverse(S)

can = True
i = 0
while i <= len(RS):
    can2 = False
    for j in range(4):
        sizeT = len(RT[j])
        if RT[j] == RS[i:sizeT]:
            i += sizeT
            can2 = True
            break

    if not can2:
        can = False
        break

if can:
    print('YES')
else:
    print('NO')
S=input()
T=["dream","dreamer","erase","eraser"]
S=S.replace(T[3],"").replace(T[2],"").replace(T[1],"").replace(T[0],"")
if S=="":
    print("YRS")
else:
    print("NO")
s = input()

mojiretu = ['dream','dreamer','erase','eraser']

import re
def setudan(s):
  if s[-5:] == 'dream' or s[-5:] == 'erase':
    return s[:-5]
  elif s[-6:] == 'eraser':
    return s[:-6]
  elif s[-7:] == 'dreamer':
    return s[:-7]
  else:
    return 0

while True:
  s = setudan(s)
  if s == 0:
    print('No')
    break
  if s =='':
    print('Yes')
    break
s = list(input())
while s:
    for c in ("dream", "dreamer", "erase", "eraser"):
        if "".join(s[-7:]).endswith(c):
            for _ in range(len(c)):
                s.pop()
            break
    else:
        print("No")
        break
else:
    print("Yes")
S = input()
string = [
    "dreamer",
    "dream",
    "eraser"
    "erase",

]

for s in string:
    S.replace(s, "1")
S.replace("1", "")
if len(S) == 0:
    print("YES")
else:
    print("NO")
s=input()
lst=["eraser","erase","dreamer","dream",]
for e in lst: 
  s=s.replace(e,"")
print(s)
print("YES" if s=="" else "NO")
S = input()
words = ['dreamer','dream','eraser','erase']
i = 0
while i < len(S):
    update = False
    for w in words:
        if S[i:].startswith(w):
            i += len(w)
            update =True
            break
    if not update:
        break
print('YES' if i == len(S) else 'NO')
S = input()
T = ['dream', 'dreamer', 'erase', 'eraser']


def reverse(t):
    return t[::-1]


RT = [reverse(t) for t in T]
RS = reverse(S)
print(RT)


for i in range(len(RS)):
    can = False
    for j in range(4):
        sizeT = len(RT[j])
        if RT[j] == RS[i:sizeT]:
            i += sizeT
            can = True
            break

    if can:
        break

if can:
    print('OK')
else:
    print('NG')
S = input()
l = ['maerd','remaerd', 'esare', 'resare']

def test(S,l):
    while len(S) > 0:
        if S[-1:-6:-1] in l:
    	    S = S[:-5]
        elif S[-1:-7:-1] in l:
    	    S = S[:-6]
        else:
      	    print('NO')
      	    return
    print('YES')
    return
  
test(S,l)
S = input()
if len(S) == 0:
  print('NO')
if len(S.replace('dreamer', '').replace('dream', '').replace('eraser', '').replace('erase', '')) == 0:
  print('YES')
else:
  print('NO')
def main(S):
    listdreamereraser = ['dreamer','eraser','dream','erase']
    while True:
        for i in listdreamereraser:
            if i in S[-len(i):]:
                S = S.replace(i,'',-1)
                break
        else:
            return False
        if len(S) == 0:
            return True

S = input()
print('YES' if main(S) else 'NO')
s=input()
ans='YES'
while s=='':
  if s[:7]=='dreamer':
    s=s[7:]
  elif s[:5]=='dream':
    s=s[5:]
  elif s[:6]=='eraser':
    s=s[6:]
  elif s[:5]=='erase':
    s=s[5:]
  else:
    ans='NO'
    break
print(ans)
s = input()

pos = len(s)
while pos >= 0:
    if s[pos-6:pos] == 'eraser':
        pos -= 6
    elif s[pos-5:pos] == 'erase':
        pos -= 5
    elif s[pos-5:pos] == 'dream':
        pos -= 5
    elif s[pos-6:pos] == 'dreamer':
        pos -= 6
    else:
        break
print('YES' if pos <= 0 else 'NO')
s = input()

if s.replace("dreamer", "").replace("dream", "").replace("eraser", "").replace("eras", ""):
    print("NO")
else:
    print("YES")
S = input()
Mozi = ["dreamer","eraser","dream","erase"]

for i in Mozi:
    T = S.replace(i,"X")
    S = T
if S not in "X":
    print("No")
else:
    print("Yes")
s = input()

while True:
  if s == "":
    print('YES')
    break
  elif s[-5:] == 'dream' or s[-5:] == 'erase':
    s = s[:-5]
  elif s[-6:] == 'erase':
    s = s[:-6]
  elif s[-7:] == 'dreamer':
    s = s[:-7]
  else:
    print('NO')
    break
s = input()
for p in range(10):
  if s[-5:] == 'dream':
    s = s[:-5]
  elif s[-7:] == 'dreamer':
    s = s[:-7]
  elif s[-5:] == 'erase':
    s = s[:-5]
  elif s[-6:] == 'eraser':
    s = s[:-6]
  if s == '':
    break
if s == '':
  print('YES')
else:
  print('NO')
s = input()
s = s.replace("eraser", "").replace("dreamer", "").replace("erase", "").replace("dream", "")
print("YES") if s == "" else print("NO")
S = input()
results = True
while results:
    for key_word in ("erase", "eraser", "dream", "dreamer"):
        if S.endswith(key_word):
            S = S[:-len(key_word)]
            continue
    if S == '':
        print("YES")
        results = False
        break
    else:
        print("NO")
        results = False
        break
s = list(input())

dream = list("dream")
dreamer = list("dreamer")
erase = list("erase")
eraser = list("eraser")

s.reverse()
dream.reverse()
dreamer.reverse()
erase.reverse()
eraser.reverse()

while s != []:
    if s[0:7] == dreamer:
        del s[0:]
    elif s[0:6] == eraser:
        del s[0:]
    elif s[0:5] == dream:
        del s[0:]
    elif s[0:5] == erase:
        del s[0:]
    else:
        print("NO")
        exit()

print("YES")
S = input()
Sr = S[::-1]
token = ['dream', 'dreamer', 'erase', 'eraser']
tokenr = list(map(lambda x:x[::-1], token))
t = ''
while(len(Sr)>0):
    notFound = True
    for w in tokenr:
        if w==Sr[:len(w)]:
            Sr = Sr[len(w):]
            t+=w
            notFound = False
    if notFound:
        break
if Sr == '':
    print('Yes')
else:
    print('No')
s = list(input())
s.reverse()

while len(s) > 5:
    if s[:5] == list("maerd"):
        del s[:5]
        continue
    if s[:7] == list("remaerd"):
        del s[:7]
        continue
    if s[:5] == list("esare"):
        del s[:5]
        continue
    if s[:6] == list("resare"):
        del s[:6]
        continue
    break

if s == []:
    print("YES")
else:
    print("NO")
import re

s = input()

m = re.match(r"^(dream|dreamer|erase|eraser)+$", s)

print("No" if m is None else "Yes")
s = input()
s = s.replace('dreamer','').replace('dream','').replace('eraser','').replace('erase','')
print('YES' if s == '' else 'NO')
s = list(input())
n = len(s)
temp = ['maerd', 'remaerd', 'esare', 'resare']
s.reverse()

i = 0
while i < n:
    flag = False
    for t in temp:
        if s[:len(t)] == list(t):
            i += len(t) - 1
            flag = True
            break

    if not flag:
        print("NO")
        exit()

print("YES")
s = input()

if "dream"and "dreamer" and "eraser" and "erase" in s:
    print("YES")
else:
    print("NO")
s = input()

while s:
  if s[0:7] == 'dreamer':
    s = s[7:]
    continue
  elif s[0:6] == 'eraser':
    s = s[6:]
    continue
  elif s[0:5] in ('dream', 'erase'):
    s = s[5:]
    continue
  else:
    print('NO')
    exit(0)
print('YES')
S = input()

if S.replace("dreamer","").replace("dream","").replace("eraser","").replace("erase",""):
  print("NO")
else:
  print("YES")
S = input()[::-1]
word = ['dream','dreamer','erase','eraser']
for i in word:
    S = S.replace(i[::-1],'')
print(S)
if S == '':print('YES')
else:print('NO')
s = input()

import re
output ="NO"
s = re.sub('dreameraser', '', s)
s = re.sub('dreamerase', '', s)
s = re.sub('dreamer', '', s)
s = re.sub('eraser', '', s)
s = re.sub('erase', '', s)
if s == "":
    output = "YES"
print(output)
def main():
  s = input()
  dream = False
  erase = False

  while s:
    if s.startswith('dream'):
      s = s[5:]
      dream = True
      erase = False
    elif s.startswith('erase'):
      s = s[5:]
      dream = False
      erase = True
    elif s.startswith('er') and dream:
      s = s[2:]
      dream = False
    elif s.startswith('r') and erase:
      s = s[1:]
      erase = False
    else:
      return False
  
  return True

if main():
  print('Yes')
else:
  print('No')
S = input()[::-1]
string = list(map(
    lambda x: x[::-1],
    [
        "dream",
        "dreamer",
        "erase",
        "eraser"
    ]))
index = 0
while 1:
    for x in string:
        match = S.find(x, index)
        if match == -1:
            continue
        elif match > -1:
            index += len(x)
        if index == len(S):
            print("YES")
            exit()
S = input()[::-1]
S = S.replace('dream'[::-1], '').replace('erase'[::-1], '').replace(
    'eraser'[::-1], '').replace('dreamer'[::-1], '')

if len(S) == 0:
    print('YES')
else:
    print('NO')
S = input()
while len(S) > 0:
    if S[-5::1] == 'dream' or S[-5::1] == 'erase':
        S = S[:-5:1]
    elif S[-6::1] == 'eraser':
        S = S[:-6:1]
    elif S[-7::1] == 'dreamer':
        S = S[:-7:1]
    else:
        print('No')
        break

if len(S) == 0:
    print('Yes')
s = input()


def solve(query):
    while 1:
        for frag in ("erase", "eraser", "dream", "dreamer"):
            if query.endswith(frag):
                query = query[:-len(frag)]
                break
        else:
            print("NO", query)
            break
        if not query:
            print("YES")
            break



solve(s)
S = input()[::-1]
word = ['dream'[::-1], 'dreamer'[::-1], 'erase'[::-1], 'eraser'[::-1]]
judge = [True, True, True, True]
while any(judge):
  for i in range(len(word)):
    if S[:len(word[i])] == word[i]:
      S = S[len(word[i]):]
    else:
      judge[i] = False
    if S == '':
      print('YES')
      exit()
print('No')
s = input()
A=["","dream","dreamer","erase","eraser"]
flag=0
for a in range(0,5):
    for b in range(0,5):
        for c in range(0,5):
            for d in range(0,5):
                if a!=b or a!=c or a!=d or b!=c:
                    T=A[a]+A[b]+A[c]+A[d]
                    if s==T:
                        flag=1
if flag==1:
    print("Yes")
else:
    print("No")
import re;
s = input();
print("Yes" if re.match(r'^(dream|dreamer|eraser|erase)*$', s) else "NO")
s = input()
i = 0

while i < len(s):
    print(i)
    if s[i:i+11] == "dreameraser":
        i += 11
    elif s[i:i+10] == "dreamerase":
        i += 10
    elif s[i:i+5] == "dream" or s[i:i+5] == "erase":
        i += 5
    elif s[i:i+6] =="dreamer" or s[i:i+6] == "eraser":
        i += 6
    else:
        print("NO")
        exit()

print("YES")
S = input()
S = S[::-1]
candidacies = ["dream", "dreamer", "erase", "eraser"]
candidacies = [c[::-1] for c in candidacies]

fi_flg = False
while fi_flg is False:
  if S[:7] in candidacies:
    S = S[7:]
  elif S[:6] in candidacies:
    S = S[6:]
  elif S[:5] in candidacies:
    S = S[:5]
  else:
    fi_flg = True

if len(S) == 0:
  print("YES")
else:
  print("NO")
c = input().rstrip('\n')


str1 = "dreamer"
str2 = "dream"
str3 = "eraser"
str4 = "erase"


count = 0

while(count < len(c)):
  if(c[count:count+len(str1)] == str1):
    count += len(str1)
  elif(c[count:count+len(str2)] == str2):
    count += len(str2)
  elif(c[count:count+len(str3)] == str3):
    count += len(str3)
  elif(c[count:count+len(str4)] == str4):
    count += len(str4)
  else:
    print("NO")
    exit()

print("YES")
s=input()
s=s[::-1]
#print(s[:5],s[:7])

for i in range(100000):
    if s[:5] == 'maerd' or s[:6] == 'esare':
        s = s[5:]
    if s[:6] == 'resare':
        s = s[6:]
    if s[:7] == 'remaerd':
        s = s[7:]

#print(s)
if len(s)==0:
    print('YES')
else:
    print('NO')
S=input()

for i in range(10000):
  if S[-7:]=="dreamer":
    S=S[:-7]
  elif S[-6:]=="eraser":
    S=S[:-6]
  elif S[-5:]=="dream" or S[-5:]=="erase":
    S=S[:-5]
  else:
    pass
  if S=="":
    print("YES")
    break
else:
  print("NO")
import re
s = input()

s = re.sub("dreameraser", "", s)
s = re.sub("dreamerase", "", s)
s = re.sub("dreamer", "", s)
s = re.sub("dream", "", s)
s = re.sub("eraser", "", s)
s = re.sub("erase", "", s)

if s == "":
    print("YES")
else:
    print("NO")
s=input()
while len(s)>7:
    if s[-5:]=='erase' or s[-5:]=='dream':
        s=s[:-5]
    elif s[-6:]=='eraser':
        s=s[-6:]
    elif s[-7:]=='dreamer':
        s=s[:-7]
    else:
        break
if s=='' or s=='dreamer' or s=='eraser' or s=='erase' or s=='eraser':
    print('YES')
else:
    print('NO')
li = input()
list = ['dream','dreamer','erase','eraser']
flag = 'No'
for x in list:
  for y in list:
    z = x + y
    if z == li:
      flag = 'YES'
      
  
print(flag)
S = input()
ls = {"dream","dreamer","erase","eraser"}
now = ""
for i in range(len(S)):
  now += S[i]
  if now in ls:
    if S[i] == "e":
      continue
    else:
      now = ""
if now == "":
  print("YES")
else:
  print("NO")
S = input()
l = ['maerd','remaerd', 'esare', 'resare']

def test(S,l):
    tmpS = S
    while len(tmpS) > 0:
        if tmpS[::-1] in l:
            print('YES')
            return
        if tmpS[-1:-6:-1] in l:
            tmpS = tmpS[:-5]
        elif tmpS[-1:-7:-1] in l:
            tmpS = tmpS[:-6]
        else:
      	    print('NO')
      	    return
    #print('YES')
    #return
  
test(S,l)
S=input()
str_list=["dream","dreamer","erase","eraser"]

S_tmp=""
while True:
  S_tmp=S
  for str in str_list:
    S=S.replace(str,"") #rstrip(str)はだめ
  
  if S_tmp==S:
    break

if S=="":
  print("YES")
if S!="":
  print("NO")
s=input()[::-1]
words = {"dream", "dreamer", "erase", "eraser"}

for i in words:
    print(i[::-1])
    s = s.replace(i[::-1],'')

print("NO"if len(s)!=0else "YES")
def main():
  S = input()
  while len(S)>=5:
    if len(S)>=7 and S[-7:]=="dreamer":
      S = S[:-7]
      continue
    
    elif len(S)>=6 and S[-6:]=="eraser":
      S = S[:-6]
      continue
    elif S[-5:]=="dream" or S[-5:]=="erase":
      S = S[:-5]
      continue
    else:
      break
  if len(S)==0:
    print('Yes')
  else:
    print('No')
    
main()
import re

S = input()

s = re.sub(r"(dream)|(erase)|(dreamer)|(eraser)", "", S)
if len(s) == 0:
    print("YES")
else:
    print("NO")
S=input()

for i in range(10000):
  if S[-7:]=="dreamer":
    S=S[:-7]
  elif S[-6:]=="eraser":
    S=S[:-6]
  elif S[-5:]=="dream" or S[-5:]=="erase":
    S=S[:-5]
  else:
    pass
  if S==[]:
    print("YES")
    break
else:
  print("NO")
a = input()

b = a[::-1]

i = 0
while i  < len(b):
    if b[i:i+5] == "esare":
        i += 5
    elif b[i:i+5] == "maerd":
        i += 5
    elif b[i:i+6] == "resare":
        i += 6
    elif b[i:i+7] == "remaerd":
        i += 7
    else:
        ans = "No"
        break

if i  == len(b):
    ans = "Yes"
else:
    ans = "No"

print(ans)
s_init = input()
s_list = list(reversed(s_init))
s = ''.join(s_list)
t = ""
words = ["maerd", "remaerd", 'esare', 'resare']
s_list = list(s)
t_list = list(t)
while s != t:
    if len(s_list) < len(t_list):
        break
    elif t == 'gameover':
        break
    for word in words:
        if s.startswith(t + word):
            t = t + word
            break
        else:
            t = 'gameover'
if s == t:
    print('YES')
else:
    print('NO')