-----Input-----

The input consists of a single string of uppercase letters A-Z. The length of the string is between 1 and 10 characters, inclusive.


-----Output-----

Output "YES" or "NO".


-----Examples-----
Input
GENIUS

Output
YES

Input
DOCTOR

Output
NO

Input
IRENE

Output
YES

Input
MARY

Output
NO

Input
SMARTPHONE

Output
NO

Input
REVOLVER

Output
YES

Input
HOLMES

Output
NO

Input
WATSON

Output
YES

Difficulty: interview

Starter code:

Solutions:
k = '''	
H	
He	
Li
Be	
B
C
N
O
F
Ne	
Na
Mg	
Al
Si
P
S
Cl
Ar	
K
Ca	
Sc
Ti
V
Cr
Mn
Fe
Co
Ni
Cu
Zn
Ga
Ge
As
Se
Br
Kr
5	
Rb
Sr	
Y
Zr
Nb
Mo
Tc
Ru
Rh
Pd
Ag
Cd
In
Sn
Sb
Te
I
Xe	
Cs
Ba
La
Ce
Pr
Nd
Pm
Sm
Eu
Gd
Tb
Dy
Ho
Er
Tm
Yb
Lu
Hf
Ta
W
Re
Os
Ir
Pt
Au
Hg
Tl
Pb
Bi
Po
At
Rn	
Fr
Ra
Ac
Th
Pa
U
Np
Pu
Am
Cm
Bk
Cf
Es
Fm
Md
No
Lr
Rf
Db
Sg
Bh
Hs
Mt
Ds
Rg
Cn
Nh
Fl
Mc
Lv
Ts
Og	
Uue
Ubn
Ubu
Ubb
Ubt
Ubq
Ubp
Ubh
Ubs
'''.upper().split()

s = '0' + input()
dp = [0] * (len(s))
dp[0] = 1
for i in range(1, len(s)):
    for j in range(1, 3):
        if s[i - j + 1: i + 1] in k: dp[i] |= dp[i - j]
print("YES" if dp[-1] else "NO")

elements = "H He Li Be B C N O F Ne Na Mg Al Si P S Cl Ar K Ca Sc Ti V Cr Mn Fe Co Ni Cu Zn Ga Ge As Se Br Kr Rb Sr Y Zr Nb Mo Tc Ru Rh Pd Ag Cd In Sn Sb Te I Xe Cs Ba La Ce Pr Nd Pm Sm Eu Gd Tb Dy Ho Er Tm Yb Lu Hf Ta W Re Os Ir Pt Au Hg Tl Pb Bi Po At Rn Fr Ra Ac Th Pa U Np Pu Am Cm Bk Cf Es Fm Md No Lr Rf Db Sg Bh Hs Mt Ds Rg Cn Nh Fl Mc Lv Ts Og".split()

def decompose(word):
    """Express given word as chemical compound. If there are multiple solutions, return one of minimal weight."""
    progress = [False for x in range(len(word)+1)] # solution for word[:i]
    progress[0] = []

    for i in range(1, len(word)+1):
        possibles = list()
        for j in range(max(i-3,0), i):
            if progress[j] == False:
                continue
            alchemical = word[j:i].title()
            if alchemical in elements:
                possibles.append(progress[j] + [alchemical])

        if possibles:
            # choose minimal solution
            progress[i] = min(possibles, key=len)

    if progress[-1] == False:
        return False
    return "".join(progress[-1])

print("YES" if decompose(input()) else "NO")


l = """H
He
Li
Be
B
C
N
O
F
Ne
Na
Mg
Al
Si
P
S
Cl
Ar
K
Ca
Sc
Ti
V
Cr
Mn
Fe
Co
Ni
Cu
Zn
Ga
Ge
As
Se
Br
Kr
Rb
Sr
Y
Zr
Nb
Mo
Tc
Ru
Rh
Pd
Ag
Cd
In
Sn
Sb
Te
I
Xe
Cs
Ba
La
Ce
Pr
Nd
Pm
Sm
Eu
Gd
Tb
Dy
Ho
Er
Tm
Yb
Lu
Hf
Ta
W
Re
Os
Ir
Pt
Au
Hg
Tl
Pb
Bi
Po
At
Rn
Fr
Ra
Ac
Th
Pa
U
Np
Pu
Am
Cm
Bk
Cf
Es
Fm
Md
No
Lr
Rf
Db
Sg
Bh
Hs
Mt
Ds
Rg
Cn
Nh
Fl
Mc
Lv
Ts
Og""".split()
l = list([x.lower() for x in l])
inp = input().strip().lower()
dp = [True]
for i in range(len(inp)):
    works = False
    if dp[-1] and inp[i] in l:
        works = True
    if i and dp[-2] and inp[i-1:i+1] in l:
        works = True
    dp.append(works)
if dp[-1]:
    print('YES')
else:
    print('NO')


table = "H He Li Be B C N O F Ne Na Mg Al Si P S Cl Ar K Ca Sc Ti V Cr Mn Fe Co Ni Cu Zn Ga Ge As Se Br Kr Rb Sr Y Zr Nb Mo Tc Ru Rh Pd Ag Cd In Sn Sb Te I Xe Cs Ba La Ce Pr Nd Pm Sm Eu Gd Tb Dy Ho Er Tm Yb Lu Hf Ta W Re Os Ir Pt Au Hg Tl Pb Bi Po At Rn Fr Ra Ac Th Pa U Np Pu Am Cm Bk Cf Es Fm Md No Lr Rf Db Sg Bh Hs Mt Ds Rg Cn Nh Fl Mc Lv Ts Og Uue Ubn Ubu Ubb Ubt Ubq Ubp Ubh Ubs"
elements = [x.upper() for x in table.split()]
def elementary(word):
    if word == "":
        return True
    if word[0:1] in elements and elementary(word[1:]):
        return True
    if word[0:2] in elements and elementary(word[2:]):
        return True
    if word[0:3] in elements and elementary(word[3:]):
        return True
    return False
word = input()
if elementary(word):
    print("YES")
else:
    print("NO")

elements = set("H He Li Be B C N O F Ne Na Mg Al Si P S Cl Ar K Ca Sc Ti V Cr Mn Fe Co Ni Cu Zn Ga Ge As Se Br Kr Rb Sr Y Zr Nb Mo Tc Ru Rh Pd Ag Cd In Sn Sb Te I Xe Cs Ba La Ce Pr Nd Pm Sm Eu Gd Tb Dy Ho Er Tm Yb Lu Hf Ta W Re Os Ir Pt Au Hg Tl Pb Bi Po At Rn Fr Ra Ac Th Pa U Np Pu Am Cm Bk Cf Es Fm Md No Lr Rf Db Sg Bh Hs Mt Ds Rg Cn Nh Fl Mc Lv Ts Og".upper().split())

def is_elem(s):
    if not s: return True
    return (s[:1] in elements and is_elem(s[1:])) or (s[:2] in elements and is_elem(s[2:]))
print("YNEOS"[not is_elem(input())::2])


ele = ["H","HE","LI","BE","B","C","N","O","F","NE","NA","MG","AL","SI","P","S","CL","AR","K","CA","SC","TI","V","CR","MN","FE","CO","NI","CU","ZN","GA","GE","AS","SE","BR","KR","RB","SR","Y","ZR","NB","MO","TC","RU","RH","PD","AG","CD","IN","SN","SB","TE","I","XE","CS","BA","LA","CE","PR","ND","PM","SM","EU","GD","TB","DY","HO","ER","TM","YB","LU","HF","TA","W","RE","OS","IR","PT","AU","HG","TL","PB","BI","PO","AT","RN","FR","RA","AC","TH","PA","U","NP","PU","AM","CM","BK","CF","ES","FM","MD","NO","LR","RF","DB","SG","BH","HS","MT","DS","RG","CN","NH","FL","MC","LV","TS","OG"]
ele = set(ele)
s = input()
n = len(s)
for b in range(1<<(n-1)):
	es = []
	tmp = s[0]
	for i in range(1, n):
		if (b>>(i-1)) & 1:
			tmp += s[i]
		else:
			es.append(tmp)
			tmp = s[i]
	if tmp != "":
		es.append(tmp)
	ok = True
	for e in es:
		if e not in ele:
			ok = False
	if ok:
		print("YES")
		break
else:
	print("NO")

elements = ['AC','AG','AL','AM','AR','AS','AT','AU','B','BA','BE','BH','BI',
            'BK','BR','C','CA','CD','CE','CF','CL','CM','CN','CO','CR','CS',
            'CU','DB','DS','DY','ER','ES','EU','F','FE','FL','FM','FR','GA',
            'GD','GE','H','HE','HF','HG','HO','HS','I','IN','IR','K','KR',
            'LA','LI','LR','LU','LV','MC','MD','MG','MN','MO','MT','N','NA',
            'NB','ND','NE','NH','NI','NO','NP','O','OG','OS','P','PA','PB','PD',
            'PM','PO','PR','PT','PU','RA','RB','RE','RF','RG','RH','RN','RU','S',
            'SB','SC','SE','SG','SI','SM','SN','SR','TA','TB','TC','TE','TH','TI',
            'TL','TM','TS','U','V','W','XE','Y','YB','ZN','ZR']

def check(word):
    ans = False
    for element in elements:
        if word == element:
            return True
        l = len(element)
        if len(word) > l and word[0:l] == element:
            ans = ans or check(word[l:])
    return ans

w = input()
if check(w):
    print('YES')
else:
    print('NO')

elements = {
    'H',
    'HE',
    'LI',
    'BE',
    'B',
    'C',
    'N',
    'O',
    'F',
    'NE',
    'NA',
    'MG',
    'AL',
    'SI',
    'P',
    'S',
    'CL',
    'AR',
    'K',
    'CA',
    'SC',
    'TI',
    'V',
    'CR',
    'MN',
    'FE',
    'CO',
    'NI',
    'CU',
    'ZN',
    'GA',
    'GE',
    'AS',
    'SE',
    'BR',
    'KR',
    'RB',
    'SR',
    'Y',
    'ZR',
    'NB',
    'MO',
    'TC',
    'RU',
    'RH',
    'PD',
    'AG',
    'CD',
    'IN',
    'SN',
    'SB',
    'TE',
    'I',
    'XE',
    'CS',
    'BA',
    'LA',
    'CE',
    'PR',
    'ND',
    'PM',
    'SM',
    'EU',
    'GD',
    'TB',
    'DY',
    'HO',
    'ER',
    'TM',
    'YB',
    'LU',
    'HF',
    'TA',
    'W',
    'RE',
    'OS',
    'IR',
    'PT',
    'AU',
    'HG',
    'TL',
    'PB',
    'BI',
    'PO',
    'AT',
    'RN',
    'FR',
    'RA',
    'AC',
    'TH',
    'PA',
    'U',
    'NP',
    'PU',
    'AM',
    'CM',
    'BK',
    'CF',
    'ES',
    'FM',
    'MD',
    'NO',
    'LR',
    'RF',
    'DB',
    'SG',
    'BH',
    'HS',
    'MT',
    'DS',
    'RG',
    'CN',
    'NH',
    'FL',
    'MC',
    'LV',
    'TS',
    'OG',
}

res = False

def test(s):
    if s == '':
        nonlocal res
        res = True
    if s[:1] in elements:
        test(s[1:])
    if s[:2] in elements:
        test(s[2:])

s = input()
test(s)
print(['NO', 'YES'][res])



#!/bin/python3

import sys

elements = [
    "H",  "He", "Li", "Be", "B",  "C",  "N",  "O",  "F",  "Ne",
    "Na", "Mg", "Al", "Si", "P",  "S",  "Cl", "Ar", "K",  "Ca",
    "Sc", "Ti", "V",  "Cr", "Mn", "Fe", "Co", "Ni", "Cu", "Zn",
    "Ga", "Ge", "As", "Se", "Br", "Kr", "Rb", "Sr", "Y",  "Zr",
    "Nb", "Mo", "Tc", "Ru", "Rh", "Pd", "Ag", "Cd", "In", "Sn",
    "Sb", "Te", "I",  "Xe", "Cs", "Ba", "La", "Ce", "Pr", "Nd",
    "Pm", "Sm", "Eu", "Gd", "Tb", "Dy", "Ho", "Er", "Tm", "Yb",
    "Lu", "Hf", "Ta", "W",  "Re", "Os", "Ir", "Pt", "Au", "Hg",
    "Tl", "Pb", "Bi", "Po", "At", "Rn", "Fr", "Ra", "Ac", "Th",
    "Pa", "U",  "Np", "Pu", "Am", "Cm", "Bk", "Cf", "Es", "Fm",
    "Md", "No", "Lr", "Rf", "Db", "Sg", "Bh", "Hs", "Mt", "Ds",
    "Rg", "Cn", "Nh", "Fl", "Mc", "Lv", "Ts", "Og"]

lower = [x.lower() for x in elements]

word = input().lower()

s = "" # current
t = None # current + 1
si = -1
ti = None

if word[0] in lower:
	t = elements[lower.index(word[0])] + " "
	ti = 0

while True:
#	print(s, si, t, ti)
	if si == None and ti == None:
		print("NO")
		return
	if si != None and si == len(word) - 1:
		print("YES")
		return
	if ti != None and ti == len(word) - 1:
		print("YES")
		return
	newT = None
	newTi = None
	newS = t
	newSi = ti
	# get new T
	if ti != None:
		# try advance t by one
		if word[ti+1] in lower:
			newTi = ti + 1
			newT = t + elements[lower.index(word[ti+1])] + " "
	if newT == None: # still none
		# try advance s by 2
		if si != None:
			if word[si+1:si+3] in lower:
				newTi = si + 2
				newT = s + elements[lower.index(word[si+1:si+3])] + " "
	# get new s
	if newS == None and si != None:
		if word[si+1] in lower:
			newSi = si + 1
			newS = s + elements[lower.index(word[si+1])] + " "
	s = newS
	si = newSi
	t = newT
	ti = newTi


strs = """Ac
Ag
Al
Am
Ar
As
At
Au
B
Ba
Be
Bh
Bi
Bk
Br
C
Ca
Cd
Ce
Cf
Cl
Cm
Cn
Co
Cr
Cs
Cu
Db
Ds
Dy
Er
Es
Eu
F
Fe
Fl
Fm
Fr
Ga
Gd
Ge
H
He
Hf
Hg
Ho
Hs
I
In
Ir
K
Kr
La
Li
Lr
Lu
Lv
Mc
Md
Mg
Mn
Mo
Mt
N
Na
Nb
Nd
Ne
Nh
Ni
No
Np
O
Og
Os
P
Pa
Pb
Pd
Pm
Po
Pr
Pt
Pu
Ra
Rb
Re
Rf
Rg
Rh
Rn
Ru
S
Sb
Sc
Se
Sg
Si
Sm
Sn
Sr
Ta
Tb
Tc
Te
Th
Ti
Tl
Tm
Ts
U
Ubb
Ubh
Ubn
Ubp
Ubq
Ubt
Ubu
Uue
V
W
Xe
Y
Yb
Zn
Zr"""
ele = strs.upper().split("\n")
# print(ele)
inp = input()
n = len(inp)
dp = [False] * (n+1)
dp[0] = True
for i in range(1, n+1):
  if dp[i-1] == True and inp[i-1:i] in ele:
    dp[i] = True
  elif i > 1 and dp[i-2] == True and inp[i-2:i] in ele:
    dp[i] = True
  elif i > 2 and dp[i-3] == True and inp[i-3:i] in ele:
    dp[i] = True

if dp[n]:
  print("YES")
else:
  print("NO")

lip = ['H', 'He', 'Li', 'Be', 'B', 'C', 'N', 'O', 'F', 'Ne', 'Na', 'Mg', 'Al', 'Si', 'P', 'S', 'Cl', 'Ar', 'K', 'Ca', 'Sc', 'Ti', 'V', 'Cr', 'Mn', 'Fe', 'Co', 'Ni', 'Cu', 'Zn', 'Ga', 'Ge', 'As', 'Se', 'Br', 'Kr', 'Rb', 'Sr', 'Y', 'Zr', 'Nb', 'Mo', 'Tc', 'Ru', 'Rh', 'Pd', 'Ag', 'Cd', 'In', 'Sn', 'Sb', 'Te', 'I', 'Xe', 'Cs', 'Ba', 'La', 'Ce', 'Pr', 'Nd', 'Pm', 'Sm', 'Eu', 'Gd', 'Tb', 'Dy', 'Ho', 'Er', 'Tm', 'Yb', 'Lu', 'Hf', 'Ta', 'W', 'Re', 'Os', 'Ir', 'Pt', 'Au', 'Hg', 'Tl', 'Pb', 'Bi', 'Po', 'At', 'Rn', 'Fr', 'Ra', 'Ac', 'Th', 'Pa', 'U', 'Np', 'Pu', 'Am', 'Cm', 'Bk', 'Cf', 'Es', 'Fm', 'Md', 'No', 'Lr', 'Rf', 'Db', 'Sg', 'Bh', 'Hs', 'Mt', 'Ds', 'Rg', 'Cn', 'Nh', 'Fl', 'Mc', 'Lv', 'Ts', 'Og']
for i in range(len(lip)):
    lip[i] = lip[i].upper()

s = input()
dp = [False]*(len(s))

for i in range(len(dp)):
    #print(i)
    if (s[i] in lip):
        #print('here1')
        if (i - 1 >= 0):
            if (dp[i - 1]):
                dp[i] = True
        else:
            dp[i] = True
    if i > 0:
        #print('here2')
        a = s[i - 1] + s[i]
        #print(a)
        if (a in lip):
            if (i - 2 >= 0):
                if (dp[i - 2]):
                    dp[i] = True
            else:
                dp[i] = True
#print(dp)
if (dp[len(s) - 1]):
    print('YES')
else:
    print('NO')


elems = ['H', 'HE', 'LI', 'BE', 'B', 'C', 'N', 'O', 'F', 'NE', 'NA', 'MG', 'AL', 'SI', 'P', 'S', 'CL', 'AR', 'K', 'CA', 'SC', 'TI', 'V', 'CR', 'MN', 'FE', 'CO', 'NI', 'CU', 'ZN', 'GA', 'GE', 'AS', 'SE', 'BR', 'KR', 'RB', 'SR', 'Y', 'ZR', 'NB', 'MO', 'TC', 'RU', 'RH', 'PD', 'AG', 'CD', 'IN', 'SN', 'SB', 'TE', 'I', 'XE', 'CS', 'BA', 'LA', 'CE', 'PR', 'ND', 'PM', 'SM', 'EU', 'GD', 'TB', 'DY', 'HO', 'ER', 'TM', 'YB', 'LU', 'HF', 'TA', 'W', 'RE', 'OS', 'IR', 'PT', 'AU', 'HG', 'TL', 'PB', 'BI', 'PO', 'AT', 'RN', 'FR', 'RA', 'AC', 'TH', 'PA', 'U', 'NP', 'PU', 'AM', 'CM', 'BK', 'CF', 'ES', 'FM', 'MD', 'NO', 'LR', 'RF', 'DB', 'SG', 'BH', 'HS', 'MT', 'DS', 'RG', 'CN', 'NH', 'FL', 'MC', 'LV', 'TS', 'OG']

s = input()


dp = [False for i in range(len(s)+1)]
dp[0] = True

for i in range(len(s)):
    if not dp[i]: continue
    for el in elems:
        if s[i:].startswith(el):
            dp[i+len(el)] = True

print('YES' if dp[-1] else 'NO')


elems = ['H','HE','LI','BE','B','C','N','O','F','NE','NA','MG','AL','SI','P','S','CL','AR','K','CA','SC','TI','V','CR','MN','FE','CO','NI','CU','ZN','GA','GE','AS','SE','BR','KR','RB','SR','Y','ZR','NB','MO','TC','RU','RH','PD','AG','CD','IN','SN','SB','TE','I','XE','CS','BA','LA','CE','PR','ND','PM','SM','EU','GD','TB','DY','HO','ER','TM','YB','LU','HF','TA','W','RE','OS','IR','PT','AU','HG','TL','PB','BI','PO','AT','RN','FR','RA','AC','TH','PA','U','NP','PU','AM','CM','BK','CF','ES','FM','MD','NO','LR','RF','DB','SG','BH','HS','MT','DS','RG','CN','NH','FL','MC','LV','TS','OG']

s = str(input())

cando = [False] * len(s)

good = False
for elem in elems:
    if s.startswith(elem):
        cando[len(elem)-1] = True

for i in range(1, len(s)):
    for elem in elems:
        ln = len(elem)
        if ln > i + 1:
            continue
        
        substr = s[i+1-ln:i+1]
        if substr == elem:
            cando[i] = cando[i] or cando[i-ln]
    
if cando[len(s)-1]:
    print('YES')
else:
    print('NO')

"""
with open('elements.txt', 'r') as e:
    ele = e.read()
    
ele = ele.split('\n')

elements = []

for elem in ele:
    if len(elem) > 0:
        parts = elem.split('-')
        element = parts[0].strip()
        elements.append(element)
        
res = '['
for elem in elements:
    res = res + "'" + elem.upper() + "',"
res = res[:-1]
res += ']'

print(res)
"""

elems = set(['H', 'HE', 'LI', 'BE', 'B', 'C', 'N', 'O', 'F', 'NE', 'NA', 'MG', 'AL', 'SI', 'P', 'S', 'CL', 'AR', 'K', 'CA', 'SC', 'TI', 'V', 'CR', 'MN', 'FE', 'CO', 'NI', 'CU', 'ZN', 'GA', 'GE', 'AS', 'SE', 'BR', 'KR', 'RB', 'SR', 'Y', 'ZR', 'NB', 'MO', 'TC', 'RU', 'RH', 'PD', 'AG', 'CD', 'IN', 'SN', 'SB', 'TE', 'I', 'XE', 'CS', 'BA', 'HF', 'TA', 'W', 'RE', 'OS', 'IR', 'PT', 'AU', 'HG', 'TL', 'PB', 'BI', 'PO', 'AT', 'RN', 'FR', 'RA', 'RF', 'DB', 'SG', 'BH', 'HS', 'MT', 'DS', 'RG', 'CN', 'NH', 'FL', 'MC', 'LV', 'TS', 'OG', 'LA', 'CE', 'PR', 'ND', 'PM', 'SM', 'EU', 'GD', 'TB', 'DY', 'HO', 'ER', 'TM', 'YB', 'LU', 'AC', 'TH', 'PA', 'U', 'NP', 'PU', 'AM', 'CM', 'BK', 'CF', 'ES', 'FM', 'MD', 'NO', 'LR'])

s = input()
n = len(s)
dp = [False for _ in range(n + 1)]
dp[0] = True
for i in range(n):
    if not dp[i]:
        continue
    if s[i] in elems:
        dp[i + 1] = True
    if i + 2 <= n and s[i:i+2] in elems:
        dp[i + 2] = True

print('YES' if dp[n] else 'NO')


elements = [
'Ac',
'Ag',
'Al',
'Am',
'Ar',
'As',
'At',
'Au',
'B',
'Ba',
'Be',
'Bh',
'Bi',
'Bk',
'Br',
'C',
'Ca',
'Cd',
'Ce',
'Cf',
'Cl',
'Cm',
'Cn',
'Co',
'Cr',
'Cs',
'Cu',
'Db',
'Ds',
'Dy',
'Er',
'Es',
'Eu',
'F',
'Fe',
'Fl',
'Fm',
'Fr',
'Ga',
'Gd',
'Ge',
'H',
'He',
'Hf',
'Hg',
'Ho',
'Hs',
'I',
'In',
'Ir',
'K',
'Kr',
'La',
'Li',
'Lr',
'Lu',
'Lv',
'Mc',
'Md',
'Mg',
'Mn',
'Mo',
'Mt',
'N',
'Na',
'Nb',
'Nd',
'Ne',
'Nh',
'Ni',
'No',
'Np',
'O',
'Og',
'Os',
'P',
'Pa',
'Pb',
'Pd',
'Pm',
'Po',
'Pr',
'Pt',
'Pu',
'Ra',
'Rb',
'Re',
'Rf',
'Rg',
'Rh',
'Rn',
'Ru',
'S',
'Sb',
'Sc',
'Se',
'Sg',
'Si',
'Sm',
'Sn',
'Sr',
'Ta',
'Tb',
'Tc',
'Te',
'Th',
'Ti',
'Tl',
'Tm',
'Ts',
'U',
'V',
'W',
'Xe',
'Y',
'Yb',
'Zn',
'Zr']

elem = list(map(lambda x: x.upper(), elements))

def find(s):
	if s == "": 
		return True

	if s[0] in elem:
		if find(s[1:]):
			return True

	if s[0:2] in elem:
		if find(s[2:]):
			return True
	return False

s = input()
if find(s):
	print("YES")
else:
	print("NO")

prvky="""Ac
Ag
Al
Am
Ar
As
At
Au
B
Ba
Be
Bh
Bi
Bk
Br
C
Ca
Cd
Ce
Cf
Cl
Cm
Cn
Co
Cr
Cs
Cu
Db
Ds
Dy
Er
Es
Eu
F
Fe
Fl
Fm
Fr
Ga
Gd
Ge
H
He
Hf
Hg
Ho
Hs
I
In
Ir
K
Kr
La
Li
Lr
Lu
Lv
Md
Mg
Mn
Mo
Mt
N
Na
Nb
Nd
Ne
Ni
No
Np
O
Os
P
Pa
Pb
Pd
Pm
Po
Pr
Pt
Pu
Ra
Rb
Re
Rf
Rg
Rh
Rn
Ru
S
Sb
Sc
Se
Sg
Si
Sm
Sn
Sr
Ta
Tb
Tc
Te
Th
Ti
Tl
Tm
U
Mc
Lv
Ts
Og
V
W
Xe
Y
Yb
Zn
Zr""".split("\n")
d={i:[] for i in "ABCDEFGHIJKLMNOPQRSTUVWXYZ"}
for i in prvky:
    d[i[0]].append(i)
mem={}
def f(string):
    if string in mem:
        return mem[string]
    if not string:return ""
    for i in d[string[0]]:
        if string.startswith(i.upper()):
            res=f(string[len(i):])
            if res!=-1:
                mem[string]=i+res
                return i+res
    return -1

s=input()
r=f(s)
if r==-1:
    print("NO")
else:print("YES")

'''import sys
a = []
for i in sys.stdin:
    if len(i) > 1:
        a.append(i.split()[0])
print(' '.join(a))'''

t = 'Ac Ag Al Am Ar As At Au B Ba Be Bh Bi Bk Br C Ca Cd Ce Cf Cl Cm Cn Co Cr Cs Cu Db Ds Dy Er Es Eu F Fe Fl Fm Fr Ga Gd Ge H He Hf Hg Ho Hs I In Ir K Kr La Li Lr Lu Lv Mc Md Mg Mn Mo Mt N Na Nb Nd Ne Nh Ni No Np O Og Os P Pa Pb Pd Pm Po Pr Pt Pu Ra Rb Re Rf Rg Rh Rn Ru S Sb Sc Se Sg Si Sm Sn Sr Ta Tb Tc Te Th Ti Tl Tm Ts U V W Xe Y Yb Zn Zr'
r = input()
m = set([i.upper() for i in t.split()])
n = len(r)
dp = [0] * (n + 2)
dp[0] = 1
for i in range(n):
    if not dp[i]:
        continue
    for j in range(1, 3):
        if r[i:i+j] in m:
            dp[i+j] = 1
if dp[n]:
    print('YES')
else:
    print('NO')



elements = ['Ac', 'Ag', 'Al', 'Am', 'Ar', 'As', 'At', 'Au', 'B', 'Ba', 'Be', 'Bh', 'Bi', 'Bk', 'Br', 'C', 'Ca', 'Cd', 'Ce', 'Cf', 'Cl', 'Cm', 'Cn', 'Co', 'Cr', 'Cs', 'Cu', 'Db', 'Ds', 'Dy', 'Er', 'Es', 'Eu', 'F', 'Fe', 'Fl', 'Fm', 'Fr', 'Ga', 'Gd', 'Ge', 'H', 'He', 'Hf', 'Hg', 'Ho', 'Hs', 'I', 'In', 'Ir', 'K', 'Kr', 'La', 'Li', 'Lr', 'Lu', 'Lv', 'Mc', 'Md', 'Mg', 'Mn', 'Mo', 'Mt', 'N', 'Na', 'Nb', 'Nd', 'Ne', 'Nh', 'Ni', 'No', 'Np', 'O', 'Og', 'Os', 'P', 'Pa', 'Pb', 'Pd', 'Pm', 'Po', 'Pr', 'Pt', 'Pu', 'Ra', 'Rb', 'Re', 'Rf', 'Rg', 'Rh', 'Rn', 'Ru', 'S', 'Sb', 'Sc', 'Se', 'Sg', 'Si', 'Sm', 'Sn', 'Sr', 'Ta', 'Tb', 'Tc', 'Te', 'Th', 'Ti', 'Tl', 'Tm', 'Ts', 'U', 'V', 'W', 'Xe', 'Y', 'Yb', 'Zn', 'Zr']
elements = [*list(map(str.upper, elements))]
target = input()
def helper(target):
    dp = [0]
    met = set([0])
    while dp:
        idx = dp.pop()
        for e in elements:
            if target.startswith(e, idx) and len(e) + idx not in met:
                if len(e) + idx == len(target):
                    print('YES')
                    return
                dp += idx + len(e),
                met.add(idx + len(e))
    print('NO')

helper(target)


s='H,HE,LI,BE,B,C,N,O,F,NE,NA,MG,AL,SI,P,S,CL,AR,K,CA,SC,TI,V,CR,MN,FE,CO,NI,CU,ZN,GA,GE,AS,SE,BR,KR,RB,SR,Y,ZR,NB,MO,TC,RU,RH,PD,AG,CD,IN,SN,SB,TE,I,XE,CS,BA,LA,CE,PR,ND,PM,SM,EU,GD,TB,DY,HO,ER,TM,YB,LU,HF,TA,W,RE,OS,IR,PT,AU,HG,TL,PB,BI,PO,AT,RN,FR,RA,AC,TH,PA,U,NP,PU,AM,CM,BK,CF,ES,FM,MD,NO,LR,RF,DB,SG,BH,HS,MT,DS,RG,CN,NH,FL,MC,LV,TS,OG'.split(',')
x=input()
a=1;b=0
for i in range(len(x)):
	a,b=x[i] in s and a or x[i-1:i+1] in s and b,a
print(['NO','YES'][a])

el = ['', 'H', 'He', 'Li', 'Be', 'B', 'C', 'N', 'O', 'F', 'Ne', 'Na', 'Mg', 'Al', 'Si', 'P', 'S', 'Cl', 'Ar', 'K', 'Ca', 'Sc', 'Ti', 'V', 'Cr', 'Mn', 'Fe', 'Co', 'Ni', 'Cu', 'Zn', 'Ga', 'Ge', 'As', 'Se', 'Br', 'Kr', 'Rb', 'Sr', 'Y', 'Zr', 'Nb', 'Mo', 'Tc', 'Ru', 'Rh', 'Pd', 'Ag', 'Cd', 'In', 'Sn', 'Sb', 'Te', 'I', 'Xe', 'Cs', 'Ba', 'La', 'Ce', 'Pr', 'Nd', 'Pm', 'Sm', 'Eu', 'Gd', 'Tb', 'Dy', 'Ho', 'Er', 'Tm', 'Yb', 'Lu', 'Hf', 'Ta', 'W', 'Re', 'Os', 'Ir', 'Pt', 'Au', 'Hg', 'Tl', 'Pb', 'Bi', 'Po', 'At', 'Rn', 'Fr', 'Ra', 'Ac', 'Th', 'Pa', 'U', 'Np', 'Pu', 'Am', 'Cm', 'Bk', 'Cf', 'Es', 'Fm', 'Md', 'No', 'Lr', 'Rf', 'Db', 'Sg', 'Bh', 'Hs', 'Mt', 'Ds', 'Rg', 'Cn', 'Nh', 'Fl', 'Mc', 'Lv', 'Ts', 'Og']
el = [x.upper() for x in el]

a = input()
dp = [True] + [False for x in a]
for i in range(1,len(a)+1):
    dp[i] = dp[i-1] and (a[i-1] in el)
    dp[i] = dp[i] or (i>=2 and dp[i-2] and (a[i-2:i] in el))

if dp[-1]:
    print("YES")
else:
    print("NO")


els = ["H","HE","LI","BE","B","C","N","O","F","NE","NA","MG","AL","SI","P","S","CL","AR","K","CA","SC","TI","V","CR","MN","FE","CO","NI","CU","ZN","GA","GE","AS","SE","BR","KR","RB","SR","Y","ZR","NB","MO","TC","RU","RH","PD","AG","CD","IN","SN","SB","TE","I","XE","CS","BA","LA","CE","PR","ND","PM","SM","EU","GD","TB","DY","HO","ER","TM","YB","LU","HF","TA","W","RE","OS","IR","PT","AU","HG","TL","PB","BI","PO","AT","RN","FR","RA","AC","TH","PA","U","NP","PU","AM","CM","BK","CF","ES","FM","MD","NO","LR","RF","DB","SG","BH","HS","MT","DS","RG","CN","NH","FL","MC","LV","TS","OG"]


def possible(s):
    if s=="":
        return True
        
    for el in els:
        if s.startswith(el) and possible(s[len(el):]):
            return True
    
    return False

s = input()

if possible(s):
    print("YES")
else:
    print("NO")


elems = """Ac
Al
Am
Sb
Ar
As
At
Ba
Bk
Be
Bi
Bh
B
Br
Cd
Ca
Cf
C
Ce
Cs
Cl
Cr
Co
Cu
Cm
Ds
Db
Dy
Es
Er
Eu
Fm
F
Fr
Gd
Ga
Ge
Au
Hf
Hs
He
Ho
H
In
I
Ir
Fe
Kr
La
Lr
Pb
Li
Lu
Mg
Mn
Mt
Md
Hg
Mo
Nd
Ne
Np
Ni
Nb
N
No
Uuo
Os
O
Pd
P
Pt
Pu
Po
K
Pr
Pm
Pa
Ra
Rn
Re
Rh
Rg
Rb
Ru
Rf
Sm
Sc
Sg
Se
Si
Ag
Na
Sr
S
Ta
Tc
Te
Tb
Tl
Th
Tm
Sn
Ti
W
U
V
Xe
Yb
Y
Zn
Zr
Cn
Nh
Fl
Mc
Lv
Ts
Og""".upper().split("\n")
#print(elems)



def does_it_work(word):
    #print(word)
    if word == '': return True
    for x in elems:
        if word.startswith(x) and does_it_work(word[len(x):]):
            return True
    return False

print("YES" if does_it_work(input()) else "NO")


s = "H,He,Li,Be,B,C,N,O,F,Ne,Na,Mg,Al,Si,P,S,Cl,Ar,K,Ca,Sc,Ti,V,Cr,Mn,Fe,Co,Ni,Cu,Zn,Ga,Ge,As,Se,Br,Kr,Rb,Sr,Y,Zr,Nb,Mo,Tc,Ru,Rh,Pd,Ag,Cd,In,Sn,Sb,Te,I,Xe,Cs,Ba,La,Ce,Pr,Nd,Pm,Sm,Eu,Gd,Tb,Dy,Ho,Er,Tm,Yb,Lu,Hf,Ta,W,Re,Os,Ir,Pt,Au,Hg,Tl,Pb,Bi,Po,At,Rn,Fr,Ra,Ac,Th,Pa,U,Np,Pu,Am,Cm,Bk,Cf,Es,Fm,Md,No,Lr,Rf,Db,Sg,Bh,Hs,Mt,Ds,Rg,Cn,Nh,Fl,Mc,Lv,Ts,Og".upper()
elements = s.split(",")

inp = input()
n = len(inp)
f = [True] + [False] * n

for i in range(n):
    for element in elements:
        if i + 1 >= len(element) and inp[i-len(element)+1 : i+1] == element:
            f[i + 1] |= f[i - len(element) + 1]

print("YES" if f[-1] else "NO")


A = {'H', 'HE', 'LI', 'BE', 'B', 'C', 'N', 'O', 'F', 'NE', 'NA', 'MG', 'AL', 'SI', 'P', 'S', 'CL', 'AR', 'K', 'CA', 'SC', 'TI', 'V', 'CR', 'MN', 'FE', 'CO', 'NI', 'CU', 'ZN', 'GA', 'GE', 'AS', 'SE', 'BR', 'KR', 'RB', 'SR', 'Y', 'ZR', 'NB', 'MO', 'TC', 'RU', 'RH', 'PD', 'AG', 'CD', 'IN', 'SN', 'SB', 'TE', 'I', 'XE', 'CS', 'BA', 'HF', 'TA', 'W', 'RE', 'OS', 'IR', 'PT', 'AU', 'HG', 'TL', 'PB', 'BI', 'PO', 'AT', 'RN', 'FR', 'RA', 'RF', 'DB', 'SG', 'BH', 'HS', 'MT', 'DS', 'RG', 'CN', 'NH', 'FL', 'MC', 'LV', 'TS', 'OG', 'LA', 'CE', 'PR', 'ND', 'PM', 'SM', 'EU', 'GD', 'TB', 'DY', 'HO', 'ER', 'TM', 'YB', 'LU', 'AC', 'TH', 'PA', 'U', 'NP', 'PU', 'AM', 'CM', 'BK', 'CF', 'ES', 'FM', 'MD', 'NO', 'LR'}

s = input()
L = len(s)

for i in range(1 << (L-1)):
	t = ''
	for j in range(L):
		t += s[j]
		if i >> j & 1:
			t += '|'
	if all(e in A for e in t.split('|')):
		print('YES')
		break
else:
	print('NO')


3

l = ['H', 'HE',
     'LI', 'BE', 'B', 'C', 'N', 'O', 'F', 'NE',
     'NA', 'MG', 'AL', 'SI', 'P', 'S', 'CL', 'AR',
     'K', 'CA', 'SC', 'TI', 'V', 'CR', 'MN', 'FE', 'CO', 'NI', 'CU', 'ZN', 'GA', 'GE', 'AS', 'SE', 'BR', 'KR',
     'RB', 'SR', 'Y', 'ZR', 'NB', 'MO', 'TC', 'RU', 'RH', 'PD', 'AG', 'CD', 'IN', 'SN', 'SB', 'TE', 'I', 'XE',
     'CS', 'BA', 'LA', 'HF', 'TA', 'W', 'RE', 'OS', 'IR', 'PT', 'AU', 'HG', 'TL', 'PB', 'BI', 'PO', 'AT', 'RN',
     'FR', 'RA', 'AC', 'RF', 'DB', 'SG', 'BH', 'HS', 'MT', 'DS', 'RG', 'CN', 'NH', 'FL', 'MC', 'LV', 'TS', 'OG',
     'CE', 'PR', 'ND', 'PM', 'SM', 'EU', 'GD', 'TB', 'DY', 'HO', 'ER', 'TM', 'YB', 'LU',
     'TH', 'PA', 'U', 'NP', 'PU', 'AM', 'CM', 'BK', 'CF', 'ES', 'FM', 'MD', 'NO', 'LR']


def search(s):
    if len(s) == 0:
        return True
    for x in l:
        if s.startswith(x):
            i = len(x)
            if search(s[i:]):
                return True
    return False


s = input()
if search(s):
    print('YES')
else:
    print('NO')


l=set(["H","HE","LI","BE","B","C","N","O","F","NE","NA","MG","AL","SI","P","S","CL","AR","K","CA","SC","TI","V","CR","MN","FE","CO","NI","CU","ZN","GA","GE","AS","SE","BR","KR","RB","SR","Y","ZR","NB","MO","TC","RU","RH","PD","AG","CD","IN","SN","SB","TE","I","XE","CS","BA","LA","CE","PR","ND","PM","SM","EU","GD","TB","DY","HO","ER","TM","YB","LU","HF","TA","W","RE","OS","IR","PT","AU","HG","TL","PB","BI","PO","AT","RN","FR","RA","AC","TH","PA","U","NP","PU","AM","CM","BK","CF","ES","FM","MD","NO","LR","RF","DB","SG","BH","HS","MT","DS","RG","CN","NH","FL","MC","LV","TS","OG"])
def dfs(s):
    res=True
    if len(s)==0:
        return True
    elif len(s)==1:
        return s[:1] in l
    else:
        return (dfs(s[1:]) if s[:1] in l else False) or (dfs(s[2:]) if s[:2] in l else False)
print('YES' if dfs(input()) else 'NO')

periodic_table = ['H', 'He', 'Li', 'Be', 'B', 'C', 'N', 'O', 'F', 'Ne', 'Na', 'Mg', 'Al', 'Si', 'P', 'S', 'Cl', 'Ar',
                  'K', 'Ca', 'Sc', 'Ti', 'V', 'Cr', 'Mn', 'Fe', 'Co', 'Ni', 'Cu', 'Zn', 'Ga', 'Ge', 'As', 'Se', 'Br', 
                  'Kr', 'Rb', 'Sr', 'Y', 'Zr', 'Nb', 'Mo', 'Te', 'Ru', 'Rh', 'Pd', 'Ag', 'Cd', 'In', 'Sn', 'Sb', 'Te', 
                  'I', 'Xe', 'Cs', 'Ba', 'La', 'Ce', 'Pr', 'Nd', 'Pm', 'Sm', 'Eu', 'Gd', 'Tb', 'Dy', 'Ho', 'Er', 'Tm', 
                  'Yb', 'Lu', 'Hf', 'Ta', 'W', 'Re', 'Os', 'Ir', 'Pt', 'Au', 'Hg', 'Tl', 'Pb', 'Bi', 'Po', 'At', 'Rn', 
                  'Fr', 'Ra', 'Ac', 'Th', 'Pa', 'U', 'Np', 'Pu', 'Am', 'Cm', 'Bk', 'Cf', 'Es', 'Fm','Md', 'No', 'Lr',
                  'Rf', 'Db', 'Sg', 'Bh', 'Hs', 'Mt', 'Ds', 'Rg', 'Cn', 'Nh', 'Fl', 'Mc', 'Lv', 'Ts', 'Og']

periodic_table = [a.lower() for a in periodic_table]

a = input().lower()

def dfs(index):
    nonlocal a
    if index >= len(a):
        return True
    if a[index] in periodic_table and dfs(index + 1):
        return True
    if index + 1 != len(a) and (a[index] + a[index + 1]) in periodic_table and dfs(index + 2):
        return True
    return False

print("YES" if dfs(0) else "NO")


elements = {'h', 'he', 'li', 'be', 'b', 'c', 'n', 'o', 'f', 'ne', 'na', 'mg', 'al', 'si', 'p', 's', 'cl', 'ar', 'k', 'ca', 'sc', 'ti', 'v', 'cr', 'mn', 'fe', 'co', 'ni', 'cu', 'zn', 'ga', 'ge', 'as', 'se', 'br', 'kr', 'rb', 'sr', 'y', 'zr', 'nb', 'mo', 'tc', 'ru', 'rh', 'pd', 'ag', 'cd', 'in', 'sn', 'sb', 'te', 'i', 'xe', 'cs', 'ba', 'la', 'ce', 'pr', 'nd', 'pm', 'sm', 'eu', 'gd', 'tb', 'dy', 'ho', 'er', 'tm', 'yb', 'lu', 'hf', 'ta', 'w', 're', 'os', 'ir', 'pt', 'au', 'hg', 'tl', 'pb', 'bi', 'po', 'at', 'rn', 'fr', 'ra', 'ac', 'th', 'pa', 'u', 'np', 'pu', 'am', 'cm', 'bk', 'cf', 'es', 'fm', 'md', 'no', 'lr', 'rf', 'db', 'sg', 'bh', 'hs', 'mt', 'ds', 'rg', 'cn', 'nh', 'fl', 'mc', 'lv', 'ts', 'og'}
word = input().lower()
def make_word(curr_remaining):
    if curr_remaining in elements:
        return True
    if curr_remaining[0] in elements:
        if make_word(curr_remaining[1:]):
            return True
    if len(curr_remaining) > 1 and curr_remaining[:2] in elements:
        if make_word(curr_remaining[2:]):
            return True
    return False

results = make_word(word)
if results:
    print('YES')
else:
    print('NO')

a = ['H','HE','LI','BE','B','C','N','O','F','NE','NA','MG','AL','SI','P','S','CL','AR','K','CA','SC','TI','V','CR','MN','FE','CO','NI','CU','ZN','GA','GE','AS','SE','BR','KR','RB','SR','Y','ZR','NB','MO','TC','RU','RH','PD','AG','CD','IN','SN','SB','TE','I','XE','CS','BA','LA','CE','PR','ND','PM','SM','EU','GD','TB','DY','HO','ER','TM','YB','LU','HF','TA','W','RE','OS','IR','PT','AU','HG','TL','PB','BI','PO','AT','RN','FR','RA','AC','TH','PA','U','NP','PU','AM','CM','BK','CF','ES','FM','MD','NO','LR','RF','DB','SG','BH','HS','MT','DS','RG','CN','NH','FL','MC','LV','TS','OG']

def check(s):
    if len(s) == 0:
        return 'YES'
    elif len(s) == 1:
        if s in a:
            return 'YES'
        else:
            return 'NO'
    else:
        s1 = ''
        s2 = ''
        if s[:1] in a:
            s1 = check(s[1:])
        if s[:2] in a:
            s2 = check(s[2:])
        if s1 == 'YES' or s2 == 'YES':
            return 'YES'
        else:
            return 'NO'

import sys
for line in sys.stdin:
    print(check(line[:-1]))

elements = set(["H","HE","LI","BE","B","C","N","O","F","NE","NA","MG","AL","SI","P","S","CL","AR","K","CA","SC","TI","V","CR","MN","FE","CO","NI","CU","ZN","GA","GE","AS","SE","BR","KR","RB","SR","Y","ZR","NB","MO","TC","RU","RH","PD","AG","CD","IN","SN","SB","TE","I","XE","CS","BA","LA","CE","PR","ND","PM","SM","EU","GD","TB","DY","HO","ER","TM","YB","LU","HF","TA","W","RE","OS","IR","PT","AU","HG","TL","PB","BI","PO","AT","RN","FR","RA","AC","TH","PA","U","NP","PU","AM","CM","BK","CF","ES","FM","MD","NO","LR","RF","DB","SG","BH","HS","MT","DS","RG","CN","NH","FL","MC","LV","TS","OG"])

def go(s, pos):
    if pos == len(s):
        return True

    if s[pos] in elements and go(s, pos+1):
        return True
    if pos+2 <= len(s) and s[pos:pos+2] in elements and go(s, pos+2):
        return True

    return False

s = input()
print("YES" if go(s, 0) else "NO")


els=set(['H','HE','LI','BE','B','C','N','O','F','NE','NA','MG','AL','SI','P','S','CL','AR','K','CA','SC','TI','V','CR','MN','FE','CO','NI','CU','ZN','GA','GE','AS','SE','BR','KR','RB','SR','Y','ZR','NB','MO','TC','RU','RH','PD','AG','CD','IN','SN','SB','TE','I','XE','CS','BA','LA','CE','PR','ND','PM','SM','EU','GD','TB','DY','HO','ER','TM','YB','LU','HF','TA','W','RE','OS','IR','PT','AU','HG','TL','PB','BI','PO','AT','RN','FR','RA','AC','TH','PA','U','NP','PU','AM','CM','BK','CF','ES','FM','MD','NO','LR','RF','DB','SG','BH','HS','MT','DS','RG','CN','NH','FL','MC','LV','TS','OG','UUE','UBN','UBU','UBB','UBT','UBQ','UBP','UBH'])

i=input()


a=[1]+[0]*len(i)
for j in range(len(i)):
    if i[j] in els:
        a[j+1]=max(a[j+1],a[j])
    if j and i[j-1:j+1] in els:
        a[j+1]=max(a[j+1],a[j-1])

if a[-1]:
    print("YES")
else:
    print("NO")



fuck = [
    'h','he','li','be','b','lv','nh','fl','mc','ts','og',
    'c','n','o','f','ne',
    'na','mg','al','si','p',
    's','cl','ar','k','ca',
    'sc','ti','v','cr','mn',
    'fe','co','ni','cu','zn',
    'ga','ge','as','se','br',
    'kr','rb','sr','y','zr',
    'nb','mo','tc','ru','rh',
    'pd','ag','cd','in','sn',
    'sb','te','i','xe','cs',
    'ba','la','ce','pr','nd','pm','sm','eu','gd','tb','dy','ho','er','tm','yb','lu',
    'hf','ta','w','re','os',
    'ir','pt','au','hg','tl',
    'pb','bi','po','at','rn',
    'fr','ra','ac','rf',
    'th','pa','u','np','pu','am','cm','bk','cf','es','fm','md','no','lr','db','sg','bh','hs','mt','ds','rg','cn']

def dfs(pos):
    nonlocal s,a
    if pos == len(s):
        a = 1
        return
    for i in fuck:
        if pos+len(i)<=len(s) and i == s[pos:pos+len(i)]:
            dfs(pos+len(i))
    return

s = input().strip().lower()
a = 0
dfs(0)
if a == 0:
    print("NO")
else:
    print("YES")

x = ['H', 'HE', 'LI', 'BE', 'B', 'C', 'N', 'O', 'F', 'NE', 'NA', 'MG', 'AL', 'SI', 'P', 'S', 'CL', 'AR', 'K', 'CA', 'SC', 'TI', 'V', 'CR', 'MN', 'FE', 'CO', 'NI', 'CU', 'ZN', 'GA', 'GE', 'AS', 'SE', 'BR', 'KR', 'RB', 'SR', 'Y', 'ZR', 'NB', 'MO', 'TC', 'RU', 'RH', 'PD', 'AG', 'CD', 'IN', 'SN', 'SB', 'TE', 'I', 'XE', 'CS', 'BA', 'LA', 'CE', 'PR', 'ND', 'PM', 'SM', 'EU', 'GD', 'TB', 'DY', 'HO', 'ER', 'TM', 'YB', 'LU', 'HF', 'TA', 'W', 'RE', 'OS', 'IR', 'PT', 'AU', 'HG', 'TL', 'PB', 'BI', 'PO', 'AT', 'RN', 'FR', 'RA', 'AC', 'TH', 'PA', 'U', 'NP', 'PU', 'AM', 'CM', 'BK', 'CF', 'ES', 'FM', 'MD', 'NO', 'LR', 'RF', 'DB', 'SG', 'BH', 'HS', 'MT', 'DS', 'RG', 'CN', 'NH', 'FL', 'MC', 'LV', 'TS', 'OG']
def do(s):
	if len(s) == 0:
		print("YES")
		return
	if len(s)>1:
		try:
			x.index(s[:2])
			do(s[2:])
		except ValueError:
			pass
	try: 
		x.index(s[0])
		do(s[1:])
	except ValueError:
		pass


s = input()
do(s)
print("NO")

elem = ["H","HE","LI","BE","B","C","N","O","F","NE","NA","MG","AL","SI","P","S","CL","AR","K","CA","SC","TI","V","CR","MN","FE","CO","NI","CU","ZN","GA","GE","AS","SE","BR","KR","RB","SR","Y","ZR","NB","MO","TC","RU","RH","PD","AG","CD","IN","SN","SB","TE","I","XE","CS","BA","LA","CE","PR","ND","PM","SM","EU","GD","TB","DY","HO","ER","TM","YB","LU","HF","TA","W","RE","OS","IR","PT","AU","HG","TL","PB","BI","PO","AT","RN","FR","RA","AC","TH","PA","U","NP","PU","AM","CM","BK","CF","ES","FM","MD","NO","LR","RF","DB","SG","BH","HS","MT","DS","RG","CN","NH","FL","MC","LV","TS","OG"]

def fct(t):
    if len(t) == 0:
        return True
    else:
        for x in elem:
            if(t[0] == x):
                if fct(t[1:]):
                    return True
            elif len(t) >= 2 and t[:2] == x:
                if fct(t[2:]):
                    return True
        return False

s = input()
if fct(s):
    print("YES")
else:
    print("NO")




a = ["H", "He", "Li", "Be", "B", "C", "N", "O", "F", "Ne", "Na", "Mg", "Al", "Si", "P", "S", "Cl", "Ar", "K", "Ca", "Sc", "Ti", "V", "Cr", "Mn", "Fe", "Co", "Ni", "Cu", "Zn", "Ga", "Ge", "As", "Se", "Br", "Kr", "Rb", "Sr", "Y", "Zr", "Nb", "Mo", "Tc", "Ru", "Rh", "Pd", "Ag", "Cd", "In", "Sn", "Sb", "Te", "I", "Xe", "Cs", "Ba", "Hf", "Ta", "W", "Re",
     "Os", "Ir", "Pt", "Au", "Hg", "Tl", "Pb", "Bi", "Po", "At", "Rn", "Fr", "Ra", "Rf", "Db", "Sg", "Bh", "Hs", "Mt", "Ds", "Rg", "Cn", "Nh", "Fl", "Mc", "Lv", "Ts", "Og", "La", "Ce", "Pr", "Nd", "Pm", "Sm", "Eu", "Gd", "Tb", "Dy", "Ho", "Er", "Tm", "Yb", "Lu", "Ac", "Th", "Pa", "U", "Np", "Pu", "Am", "Cm", "Bk", "Cf", "Es", "Fm", "Md", "No", "Lr"]


def f(x):
    n = len(a)
    for i in range(n):
        if (a[i] == x):
            return 1
    return 0


def dfs(cur, s, n):
    if (cur >= n):
        return 1
    flg = 0
    if (cur < n-1):
        if (f(str()+s[cur]+s[cur+1]) == 1):
            flg |= dfs(cur+2, s, n)
    if (f(s[cur]) == 1):
        flg |= dfs(cur+1, s, n)
    return flg


n = len(a)
for i in range(n):
    a[i] = a[i].upper()
s = list(input())
n = len(s)
i = 0
flg = dfs(0, s, n)
if (flg == 0):
    print("NO")
else:
    print("YES")


els = {"Ac":"Actinium","Ag":"Silver","Al":"Aluminum","Am":"Americium",
"Ar":"Argon","As":"Arsenic","At":"Astatine","Au":"Gold","B":"Boron","Ba":"Barium",
"Be":"Beryllium","Bh":"Bohrium","Bi":"Bismuth","Bk":"Berkelium","Br":"Bromine",
"C":"Carbon","Ca":"Calcium","Cd":"Cadmium","Ce":"Cerium","Cf":"Californium",
"Cl":"Chlorine","Cm":"Curium","Cn":"Copernicium","Co":"Cobalt","Cr":"Chromium",
"Cs":"Cesium","Cu":"Copper","Db":"Dubnium","Ds":"Darmstadtium","Dy":"Dysprosium",
"Er":"Erbium","Es":"Einsteinium","Eu":"Europium","F":"Fluorine","Fe":"Iron",
"Fl":"Flerovium","Fm":"Fermium","Fr":"Francium","Ga":"Gallium","Gd":"Gadolinium",
"Ge":"Germanium","H":"Hydrogen","He":"Helium","Hf":"Hafnium","Hg":"Mercury",
"Ho":"Holmium","Hs":"Hassium","I":"Iodine","In":"Indium","Ir":"Iridium",
"K":"Potassium","Kr":"Krypton","La":"Lanthanum","Li":"Lithium","Lr":"Lawrencium",
"Lu":"Lutetium","Lv":"Livermorium","Mc":"Moscovium","Md":"Mendelevium",
"Mg":"Magnesium","Mn":"Manganese","Mo":"Molybdenum","Mt":"Meitnerium",
"N":"Nitrogen","Na":"Sodium","Nb":"Niobium","Nd":"Neodymium","Ne":"Neon",
"Nh":"Nihonium","Ni":"Nickel","No":"Nobelium","Np":"Neptunium","O":"Oxygen",
"Og":"Oganesson","Os":"Osmium","P":"Phosphorus","Pa":"Protactinium","Pb":"Lead",
"Pd":"Palladium","Pm":"Promethium","Po":"Polonium","Pr":"Praseodymium",
"Pt":"Platinum","Pu":"Plutonium","Ra":"Radium","Rb":"Rubidium","Re":"Rhenium",
"Rf":"Rutherfordium","Rg":"Roentgenium","Rh":"Rhodium","Rn":"Radon",
"Ru":"Ruthenium","S":"Sulfur","Sb":"Antimony","Sc":"Scandium","Se":"Selenium",
"Sg":"Seaborgium","Si":"Silicon","Sm":"Samarium","Sn":"Tin","Sr":"Strontium",
"Ta":"Tantalum","Tb":"Terbium","Tc":"Technetium","Te":"Tellurium","Th":"Thorium",
"Ti":"Titanium","Tl":"Thallium","Tm":"Thulium","Ts":"Tennessine","U":"Uranium",
"V":"Vanadium","W":"Tungsten","Xe":"Xenon","Y":"Yttrium","Yb":"Ytterbium",
"Zn":"Zinc","Zr":"Zirconium"}

def bon(s):
    if s=="":
        return True
    if s[0] in els and bon(s[1:]):
        return True
    if len(s)>=2 and bon(s[2:]) and (s[0]+s[1].lower()) in els:
        return True
    return False

s=input()
if bon(s):
    print('YES')
else:
    print('NO')

e = [
"H ",
"He",
"Li",
"Be",
"B ",
"C ",
"N ",
"O ",
"F ",
"Ne",
"Na",
"Mg",
"Al",
"Si",
"P ",
"S ",
"Cl",
"Ar",
"K ",
"Ca",
"Sc",
"Ti",
"V ",
"Cr",
"Mn",
"Fe",
"Co",
"Ni",
"Cu",
"Zn",
"Ga",
"Ge",
"As",
"Se",
"Br",
"Kr",
"Rb",
"Sr",
"Y ",
"Zr",
"Nb",
"Mo",
"Tc",
"Ru",
"Rh",
"Pd",
"Ag",
"Cd",
"In",
"Sn",
"Sb",
"Te",
"I ",
"Xe",
"Cs",
"Ba",
"La",
"Ce",
"Pr",
"Nd",
"Pm",
"Sm",
"Eu",
"Gd",
"Tb",
"Dy",
"Ho",
"Er",
"Tm",
"Yb",
"Lu",
"Hf",
"Ta",
"W ",
"Re",
"Os",
"Ir",
"Pt",
"Au",
"Hg",
"Tl",
"Pb",
"Bi",
"Po",
"At",
"Rn",
"Fr",
"Ra",
"Ac",
"Th",
"Pa",
"U ",
"Np",
"Pu",
"Am",
"Cm",
"Bk",
"Cf",
"Es",
"Fm",
"Md",
"No",
"Lr",
"Rf",
"Db",
"Sg",
"Bh",
"Hs",
"Mt",
"Ds",
"Rg",
"Cn",
"Nh",
"Fl",
"Mc",
"Lv",
"Ts",
"Og"]

for i in range(len(e)):
    e[i] = e[i].upper().strip()

e = set(e)

s = input()

def valid(t):
    if (len(t) == 0): return 1
    if t[:1] in e and valid(t[1:]):
        return 1
    if len(t) > 1 and t[:2] in e and valid(t[2:]):
        return 1

if valid(s):
    print("YES\n")
else: print("NO\n")

def main():
    elements = ["H", "He", "Li", "Be", "B", "C", "N", "O", "F", "Ne", "Na", "Mg", "Al", "Si", "P", "S", "Cl", "Ar", "K",
                "Ca", "Sc", "Ti", "V", "Cr", "Mn", "Fe", "Co", "Ni", "Cu", "Zn", "Ga", "Ge", "As", "Se", "Br", "Kr",
                "Rb", "Sr", "Y", "Zr", "Nb", "Mo", "Tc", "Ru", "Rh", "Pd", "Ag", "Cd", "In", "Sn", "Sb", "Te", "I",
                "Xe", "Cs", "Ba", "La", "Ce", "Pr", "Nd", "Pm", "Sm", "Eu", "Gd", "Tb", "Dy", "Ho", "Er", "Tm", "Yb",
                "Lu", "Hf", "Ta", "W", "Re", "Os", "Ir", "Pt", "Au", "Hg", "Tl", "Pb", "Bi", "Po", "At", "Rn", "Fr",
                "Ra", "Ac", "Th", "Pa", "U", "Np", "Pu", "Am", "Cm", "Bk", "Cf", "Es", "Fm", "Md", "No", "Lr", "Rf",
                "Db", "Sg", "Bh", "Hs", "Mt", "Ds", "Rg", "Cn", "Nh", "Fl", "Mc", "Lv", "Ts", "Og"]
    elements = [s.upper() for s in elements]
    s = input()
    f = [True] + [False] * len(s)
    for i in range(len(s)):
        if not f[i]:
            continue
        for e in elements:
            if s[i:].startswith(e):
                f[i + len(e)] = True
    print("YES" if f[len(s)] else "NO")


def __starting_point():
    main()

__starting_point()

a=['AC','RF','DB','SG','BH','HS','MT','DS','RG','CN','NH','FL','MC','TS','OG','LV', 'AL', 'AM', 'SB', 'AR', 'AS', 'AT', 'BA', 'BK', 'BE', 'BI', 'B', 'BR', 'CD', 'CA', 'CF', 'C', 'CE', 'CS', 'CL', 'CR', 'CO', 'CU', 'CM', 'DY', 'ES', 'ER', 'EU', 'FM', 'F', 'FR', 'GD', 'GA', 'GE', 'AU', 'HF', 'HE', 'HO', 'H', 'IN', 'I', 'IR', 'FE', 'KR', 'LA', 'LR', 'PB', 'LI', 'LU', 'MG', 'MN', 'MD', 'HG', 'MO', 'ND', 'NE', 'NP', 'NI', 'NB', 'N', 'NO', 'OS', 'O', 'PD', 'P', 'PT', 'PU', 'PO', 'K', 'PR', 'PM', 'PA', 'RA', 'RN', 'RE', 'RH', 'RB', 'RU', 'SM', 'SC', 'SE', 'SI', 'AG', 'NA', 'SR', 'S', 'TA', 'TC', 'TE', 'TB', 'TL', 'TH', 'TM', 'SN', 'TI', 'W', 'U', 'V', 'XE', 'YB', 'Y', 'ZN', 'ZR']
a=set(a)
x=input()
ok=[False]*len(x)
for i in range(len(x)):
    if x[i] in a:
        ok[i]=True

for i in range(len(x)-1):
    if x[i:i+2] in a:
        ok[i]=True
        ok[i+1]=True
print('YES' if all(ok) else 'NO')

elements = """1	H	Hydrogen
2	He	Helium
3	Li	Lithium
4	Be	Beryllium
5	B	Boron
6	C	Carbon
7	N	Nitrogen
8	O	Oxygen
9	F	Fluorine
10	Ne	Neon
11	Na	Sodium
12	Mg	Magnesium
13	Al	Aluminum
14	Si	Silicon
15	P	Phosphorus
16	S	Sulfur
17	Cl	Chlorine
18	Ar	Argon
19	K	Potassium
20	Ca	Calcium
21	Sc	Scandium
22	Ti	Titanium
23	V	Vanadium
24	Cr	Chromium
25	Mn	Manganese
26	Fe	Iron
27	Co	Cobalt
28	Ni	Nickel
29	Cu	Copper
30	Zn	Zinc
31	Ga	Gallium
32	Ge	Germanium
33	As	Arsenic
34	Se	Selenium
35	Br	Bromine
36	Kr	Krypton
37	Rb	Rubidium
38	Sr	Strontium
39	Y	Yttrium
40	Zr	Zirconium
41	Nb	Niobium
42	Mo	Molybdenum
43	Tc	Technetium
44	Ru	Ruthenium
45	Rh	Rhodium
46	Pd	Palladium
47	Ag	Silver
48	Cd	Cadmium
49	In	Indium
50	Sn	Tin
51	Sb	Antimony
52	Te	Tellurium
53	I	Iodine
54	Xe	Xenon
55	Cs	Cesium
56	Ba	Barium
57	La	Lanthanum
58	Ce	Cerium
59	Pr	Praseodymium
60	Nd	Neodymium
61	Pm	Promethium
62	Sm	Samarium
63	Eu	Europium
64	Gd	Gadolinium
65	Tb	Terbium
66	Dy	Dysprosium
67	Ho	Holmium
68	Er	Erbium
69	Tm	Thulium
70	Yb	Ytterbium
71	Lu	Lutetium
72	Hf	Hafnium
73	Ta	Tantalum
74	W	Tungsten
75	Re	Rhenium
76	Os	Osmium
77	Ir	Iridium
78	Pt	Platinum
79	Au	Gold
80	Hg	Mercury
81	Tl	Thallium
82	Pb	Lead
83	Bi	Bismuth
84	Po	Polonium
85	At	Astatine
86	Rn	Radon
87	Fr	Francium
88	Ra	Radium
89	Ac	Actinium
90	Th	Thorium
91	Pa	Protactinium
92	U	Uranium
93	Np	Neptunium
94	Pu	Plutonium
95	Am	Americium
96	Cm	Curium
97	Bk	Berkelium
98	Cf	Californium
99	Es	Einsteinium
100	Fm	Fermium
101	Md	Mendelevium
102	No	Nobelium
103	Lr	Lawrencium
104	Rf	Rutherfordium
105	Db	Dubnium
106	Sg	Seaborgium
107	Bh	Bohrium
108	Hs	Hassium
109	Mt	Meitnerium
110	Ds	Darmstadtium
111	Rg	Roentgenium
112	Cn	Copernicium
113	Nh	Nihonium
114	Fl	Flerovium
115	Mc	Moscovium
116	Lv	Livermorium
117	Ts	Tennessine
118	Og	Oganesson
""".strip().split(
    "\n"
)

elements = [line.split()[1].upper() for line in elements]


def isPossible(s):
    if s in elements:
        return True
    for e in elements:
        if s.startswith(e) and isPossible(s[len(e) :]):
            return True
    return False


S = input()
if isPossible(S):
    print("YES")
else:
    print("NO")




e = [
    {'B', 'C', 'F', 'H', 'I', 'K', 'N', 'O', 'P', 'S', 'U', 'V', 'W', 'Y'},
    {'AC', 'AG', 'AL', 'AM', 'AR', 'AS', 'AT', 'AU', 'BA', 'BE', 'BH', 'BI', 'BK', 'BR', 'CA', 'CD', 'CE', 'CF', 'CL', 'CM', 'CN', 'CO', 'CR', 'CS', 'CU', 'DB', 'DS', 'DY', 'ER', 'ES', 'EU', 'FE', 'FL', 'FM', 'FR', 'GA', 'GD', 'GE', 'HE', 'HF', 'HG', 'HO', 'HS', 'IN', 'IR', 'KR', 'LA', 'LI', 'LR', 'LU', 'LV', 'MC', 'MD', 'MG', 'MN', 'MO', 'MT', 'NA', 'NB', 'ND', 'NE', 'NH', 'NI', 'NO', 'NP', 'OG', 'OS', 'PA', 'PB', 'PD', 'PM', 'PO', 'PR', 'PT', 'PU', 'RA', 'RB', 'RE', 'RF', 'RG', 'RH', 'RN', 'RU', 'SB', 'SC', 'SE', 'SG', 'SI', 'SM', 'SN', 'SR', 'TA', 'TB', 'TC', 'TE', 'TH', 'TI', 'TL', 'TM', 'TS', 'XE', 'YB', 'ZN', 'ZR'},
    {},
]

s = input()
n = len(s)
d = [0 for _ in range(n)]
for i in range(n):
    for l in range(0, 3):
        if i-l >= 0 and s[i-l:i+1] in e[l]:
            if i-l == 0 or d[i-l-1]:
                d[i] = 1
                break

print('YES' if d[n-1] else 'NO')


a = [
    "H", "HE", "LI", "BE", "B", "C", "N", "O", "F", "NE", "NA", "MG", "AL", "SI", "P", "S", "CL", "AR", "K", "CA", "SC",
    "TI", "V", "CR", "MN", "FE", "CO", "NI", "CU", "ZN", "GA", "GE", "AS", "SE", "BR", "KR", "RB", "SR", "Y", "ZR",
    "NB", "MO", "TC", "RU", "RH", "PD", "AG", "CD", "IN", "SN", "SB", "TE", "I", "XE", "CS", "BA", "LA", "CE", "PR",
    "ND", "PM", "SM", "EU", "GD", "TB", "DY", "HO", "ER", "TM", "YB", "LU", "HF", "TA", "W", "RE", "OS", "IR", "PT",
    "AU", "HG", "TL", "PB", "BI", "PO", "AT", "RN", "FR", "RA", "AC", "TH", "PA", "U", "NP", "PU", "AM", "CM", "BK",
    "CF", "ES", "FM", "MD", "NO", "LR", "RF", "DB", "SG", "BH", "HS", "MT", "DS", "RG", "CN", "NH", "FL", "MC", "LV",
    "TS", "OG",
]

b = input()
l = len(b)
ok = False


def dfs(idx):
    nonlocal b
    nonlocal ok
    if idx >= l:
        ok = True
        return
    if idx + 1 < l and str(b[idx]) + str(b[idx + 1]) in a:
        dfs(idx + 2)
    if str(b[idx]) in a:
        dfs(idx + 1)


dfs(0)
if ok:
    print("YES")
else:
    print("NO")


a = [
    "H", "HE", "LI", "BE", "B", "C", "N", "O", "F", "NE", "NA", "MG", "AL", "SI", "P", "S", "CL", "AR", "K", "CA", "SC",
    "TI", "V", "CR", "MN", "FE", "CO", "NI", "CU", "ZN", "GA", "GE", "AS", "SE", "BR", "KR", "RB", "SR", "Y", "ZR",
    "NB", "MO", "TC", "RU", "RH", "PD", "AG", "CD", "IN", "SN", "SB", "TE", "I", "XE", "CS", "BA", "LA", "CE", "PR",
    "ND", "PM", "SM", "EU", "GD", "TB", "DY", "HO", "ER", "TM", "YB", "LU", "HF", "TA", "W", "RE", "OS", "IR", "PT",
    "AU", "HG", "TL", "PB", "BI", "PO", "AT", "RN", "FR", "RA", "AC", "TH", "PA", "U", "NP", "PU", "AM", "CM", "BK",
    "CF", "ES", "FM", "MD", "NO", "LR", "RF", "DB", "SG", "BH", "HS", "MT", "DS", "RG", "CN", "NH", "FL", "MC", "LV",
    "TS", "OG",
]

b = input()
l = len(b)
ok = False


def dfs(idx):
    nonlocal ok
    if idx >= l:
        ok = True
        return
    if idx + 1 < l and str(b[idx]) + str(b[idx + 1]) in a:
        dfs(idx + 2)
    if str(b[idx]) in a:
        dfs(idx + 1)


dfs(0)
if ok:
    print("YES")
else:
    print("NO")


s = ["AC", "AG", "AL", "AM", "AR", "AS", "AT", "AU", "BA", "BE", "BH", "BI",
     "BK", "BR", "B", "CA", "CD", "CE", "CF", "CL", "CM", "CN", "CO", "CR",
	 "CS", "CU", "C", "DB", "DS", "DY", "ER", "ES", "EU", "FE", "FL", "FM",
	 "FR", "F",  "GA", "GD", "GE", "HE", "HF", "HG", "HO", "HS", "H", "IN",
	 "IR", "I",  "KR", "K",  "LA", "LI", "LR", "LU", "LV", "MC", "MD", "MG",
	 "MN", "MO", "MT", "NA", "NB", "ND", "NE", "NH", "NI", "NO", "NP", "N",
	 "OG", "OS", "O", "PA", "PB", "PD", "PM", "PO", "PR", "PT", "PU", "P",
	 "RA", "RB", "RE", "RF", "RG", "RH", "RN", "RU", "SB", "SC", "SE", "SG",
	 "SI", "SM", "SN", "SR", "S", "TA", "TB", "TC", "TE", "TH", "TI", "TL",
	 "TM", "TS", "U", "V",  "W", "XE", "YB", "Y",  "ZN", "ZR"]
def DFS(a):
    if a is "":
        return "YES"
    for j in s:
        if (len(j)==1 and a[0]==j[0] and DFS(a[1:])=="YES") or (len(a)>=2 and len(j)==2 and a[0]==j[0] and a[1]==j[1] and DFS(a[2:])=="YES"):
            return "YES"
    return "NO"
 
ss = input()
print(DFS(ss))

def ps(prakhar):
    if prakhar == "": return True
    if prakhar[0] in l and ps(prakhar[1: ]): return True
    if prakhar[0: 2] in l and ps(prakhar[2: ]): return True
    return False
l = ["H","He","Li","Be","B","C","N","O","F","Ne","Na","Mg","Al","Si","P","S","Cl","Ar","K","Ca","Sc","Ti","V","Cr","Mn","Fe","Co","Ni","Cu","Zn","Ga","Ge","As","Se","Br","Kr","Rb","Sr","Y","Zr","Nb","Mo","Tc","Ru","Rh","Pd","Ag","Cd","In","Sn","Sb","Te","I","Xe","Cs","Ba","La","Ce","Pr","Nd","Pm","Sm","Eu","Gd","Tb","Dy","Ho","Er","Tm","Yb","Lu","Hf","Ta","W","Re","Os","Ir","Pt","Au","Hg","Tl","Pb","Bi","Po","At","Rn","Fr","Ra","Ac","Th","Pa","U","Np","Pu","Am","Cm","Bk","Cf","Es","Fm","Md","No","Lr","Rf","Db","Sg","Bh","Hs","Mt","Ds","Rg","Cn","Nh","Fl","Mc","Lv","Ts","Og"]
for i in range(118):
    l[i] = l[i].upper()
s = input()
if ps(s): print("YES")
else: print("NO")

GOOD = ['GENIUS', 'IRENE', 'REVOLVER',   'WATSON']
BAD =  ['HOLMES', 'MARY',  'SMARTPHONE', 'DOCTOR']

symbols = ['Ac','Ag','Al','Am','Ar','As','At','Au','B','Ba','Be','Bh','Bi','Bk','Br','C','Ca','Cd','Ce','Cf','Cl','Cm','Cn','Co','Cr','Cs','Cu','Db','Ds','Dy','Er','Es','Eu','F','Fe','Fl','Fm','Fr','Ga','Gd','Ge','H','He','Hf','Hg','Ho','Hs','I','In','Ir','K','Kr','La','Li','Lr','Lu','Lv','Mc','Md','Mg','Mn','Mo','Mt','N','Na','Nb','Nd','Ne','Nh','Ni','No','Np','O','Og','Os','P','Pa','Pb','Pd','Pm','Po','Pr','Pt','Pu','Ra','Rb','Re','Rf','Rg','Rh','Rn','Ru','S','Sb','Sc','Se','Sg','Si','Sm','Sn','Sr','Ta','Tb','Tc','Te','Th','Ti','Tl','Tm','Ts','U','V','W','Xe','Y','Yb','Zn','Zr']
symbols = [x.upper() for x in symbols]

DP = {}
def can(w, i):
    if (w,i) in DP:
        return DP[(w,i)]
    if i == len(w):
        return True
    for s in symbols:
        if w[i:].startswith(s) and can(w, i+len(s)):
            DP[(w,i)] = True
            return True
    DP[(w,i)] = False
    return False



new = input()
print('YES' if can(new, 0) else 'NO')
#if new in GOOD:
#    print('YES')
#elif new in BAD:
#    print('NO')
#else:
#    print('YES')

def score(w):
    n = [ord(c)-ord('A')+1 for c in w]
    print(w,n,len([x for x in n if x%2==1]))

#print('== GOOD ==')
#for w in GOOD:
#    print(can(w, 0))
#print('== BAD ==')
#for w in BAD:
#    print(can(w, 0))


elements = ['H', 'He', 'Li', 'Be', 'B', 'C', 'N', 'O', 'F', 'Ne', 'Na', 'Mg', 'Al', 'Si', 'P', 'S', 'Cl', 'Ar', 'K', 'Ca', 'Sc', 'Ti', 'V', 'Cr', 'Mn', 'Fe', 'Co', 'Ni', 'Cu', 'Zn', 'Ga', 'Ge', 'As', 'Se', 'Br', 'Kr', 'Rb', 'Sr', 'Y', 'Zr', 'Nb', 'Mo', 'Tc', 'Ru', 'Rh', 'Pd', 'Ag', 'Cd', 'In', 'Sn', 'Sb', 'Te', 'I', 'Xe', 'Cs', 'Ba', 'La', 'Ce', 'Pr', 'Nd', 'Pm', 'Sm', 'Eu', 'Gd', 'Tb', 'Dy', 'Ho', 'Er', 'Tm', 'Yb', 'Lu', 'Hf', 'Ta', 'W', 'Re', 'Os', 'Ir', 'Pt', 'Au', 'Hg', 'Tl', 'Pb', 'Bi', 'Po', 'At', 'Rn', 'Fr', 'Ra', 'Ac', 'Th', 'Pa', 'U', 'Np', 'Pu', 'Am', 'Cm', 'Bk', 'Cf', 'Es', 'Fm', 'Md', 'No', 'Lr', 'Rf', 'Db', 'Sg', 'Bh', 'Hs', 'Mt', 'Ds', 'Rg', 'Cn', 'Nh', 'Fl', 'Mc', 'Lv', 'Ts', 'Og']
elements = [t.upper() for t in elements]


def dfs(s):
    if len(s) == 0:
        return True
    if len(s) >= 2 and s[:2] in elements and dfs(s[2:]):
        return True
    return s[:1] in elements and dfs(s[1:])


s = input()
print("YES" if dfs(s) else "NO")


elements = set("H He Li Be B C N O F Ne Na Mg Al Si P S Cl Ar K Ca Sc Ti V Cr Mn Fe Co Ni Cu Zn Ga Ge As Se Br Kr Rb Sr Y Zr Nb Mo Tc Ru Rh Pd Ag Cd In Sn Sb Te I Xe Cs Ba La Ce Pr Nd Pm Sm Eu Gd Tb Dy Ho Er Tm Yb Lu Hf Ta W Re Os Ir Pt Au Hg Tl Pb Bi Po At Rn Fr Ra Ac Th Pa U Np Pu Am Cm Bk Cf Es Fm Md No Lr Rf Db Sg Bh Hs Mt Ds Rg Cn Nh Fl Mc Lv Ts Og".upper().split())

def is_elem(s):
    if not s: return True
    return (s[:1] in elements and is_elem(s[1:])) or (s[:2] in elements and is_elem(s[2:]))
print("YNEOS"[not is_elem(input())::2])


e = ['AC', 'AG', 'AL', 'AM', 'AR', 'AS', 'AT', 'AU', 'B', 'BA', 'BE', 'BH', 'BI', 'BK', 'BR', 'C', 'CA', 'CD', 'CE', 'CF', 'CL', 'CM', 'CN', 'CO', 'CR', 'CS', 'CU', 'DB', 'DS', 'DY', 'ER', 'ES', 'EU', 'F', 'FE', 'FL', 'FM', 'FR', 'GA', 'GD', 'GE', 'H', 'HE', 'HF', 'HG', 'HO', 'HS', 'I', 'IN', 'IR', 'K', 'KR', 'LA', 'LI', 'LR', 'LU', 'LV', 'MC', 'MD', 'MG', 'MN', 'MO', 'MT', 'N', 'NA', 'NB', 'ND', 'NE', 'NH', 'NI', 'NO', 'NP', 'O', 'OG', 'OS', 'P', 'PA', 'PB', 'PD', 'PM', 'PO', 'PR', 'PT', 'PU', 'RA', 'RB', 'RE', 'RF', 'RG', 'RH', 'RN', 'RU', 'S', 'SB', 'SC', 'SE', 'SG', 'SI', 'SM', 'SN', 'SR', 'TA', 'TB', 'TC', 'TE', 'TH', 'TI', 'TL', 'TM', 'TS', 'U', 'V', 'W', 'XE', 'Y', 'YB', 'ZN', 'ZR']

s = input()
dp = [0] * (len(s) + 1)
dp[0] = 1
for i in range(1, len(s) + 1):
    for ei in e:
        if (len(ei) <= i and 
            ei == s[i - len(ei):i] and 
            dp[i - len(ei)] == 1):
            dp[i] = 1

print('YES' if dp[len(s)] else 'NO')

import re
if re.match( r'^(H|HE|LI|BE|B|C|N|O|F|NE|NA|MG|AL|SI|P|S|CL|AR|K|CA|SC|TI|V|CR|MN|FE|CO|NI|CU|ZN|GA|GE|AS|SE|BR|KR|RB|SR|Y|ZR|NB|MO|TC|RU|RH|PD|AG|CD|IN|SN|SB|TE|I|XE|CS|BA|LA|CE|PR|ND|PM|SM|EU|GD|TB|DY|HO|ER|TM|YB|LU|HF|TA|W|RE|OS|IR|PT|AU|HG|TL|PB|BI|PO|AT|RN|FR|RA|AC|TH|PA|U|NP|PU|AM|CM|BK|CF|ES|FM|MD|NO|LR|RF|DB|SG|BH|HS|MT|DS|RG|CN|NH|FL|MC|LV|TS|OG)*$', input()):
    print("YES")
else:
    print("NO")

"""
Author: guiferviz
Time: 2020-04-01 16:35:01
"""


def main():
    # Read input word.
    s = input()

    # Declare variables.
    elements = ["H","He","Li","Be","B","C","N","O","F","Ne","Na","Mg","Al","Si","P","S","Cl","Ar","K","Ca","Sc","Ti","V","Cr","Mn","Fe","Co","Ni","Cu","Zn","Ga","Ge","As","Se","Br","Kr","Rb","Sr","Y","Zr","Nb","Mo","Tc","Ru","Rh","Pd","Ag","Cd","In","Sn","Sb","Te","I","Xe","Cs","Ba","La","Ce","Pr","Nd","Pm","Sm","Eu","Gd","Tb","Dy","Ho","Er","Tm","Yb","Lu","Hf","Ta","W","Re","Os","Ir","Pt","Au","Hg","Tl","Pb","Bi","Po","At","Rn","Fr","Ra","Ac","Th","Pa","U","Np","Pu","Am","Cm","Bk","Cf","Es","Fm","Md","No","Lr","Rf","Db","Sg","Bh","Hs","Mt","Ds","Rg","Cn","Nh","Fl","Mc","Lv","Ts","Og"]
    #elements = ["Bi", "O"]
    elements = [i.upper() for i in elements]
    n = len(s)
    dp = [False] * (n + 1)
    dp[0] = True

    # Run code.
    for i in range(n):
        #print(i, dp)
        if dp[i]:
            for e in elements:
                if s[i:].startswith(e):
                    dp[i + len(e)] = True

    # Print result.
    print("YES" if dp[-1] else "NO")


def __starting_point():
    main()


__starting_point()

e = ['H','HE','LI','BE','B','C','N','O','F','NE','NA','MG','AL','SI','P','S','CL','AR','K','CA','SC','TI','V','CR','MN','FE','CO','NI','CU','ZN','GA','GE','AS','SE','BR','KR','RB','SR','Y','ZR','NB','MO','TC','RU','RH','PD','AG','CD','IN','SN','SB','TE','I','XE','CS','BA','LA','CE','PR','ND','PM','SM','EU','GD','TB','DY','HO','ER','TM','YB','LU','HF','TA','W','RE','OS','IR','PT','AU','HG','TL','PB','BI','PO','AT','RN','FR','RA','AC','TH','PA','U','NP','PU','AM','CM','BK','CF','ES','FM','MD','NO','LR','RF','DB','SG','BH','HS','MT','DS','RG','CN','NH','FL','MC','LV','TS','OG']
def c(s):
    if s in e:
        return True
    return any(s.startswith(x) and c(s[len(x):]) for x in e)
print(['NO','YES'][c(input())])

e = ['H','HE','LI','BE','B','C','N','O','F','NE','NA','MG','AL','SI','P','S','CL','AR','K','CA','SC','TI','V','CR','MN','FE','CO','NI','CU','ZN','GA','GE','AS','SE','BR','KR','RB','SR','Y','ZR','NB','MO','TC','RU','RH','PD','AG','CD','IN','SN','SB','TE','I','XE','CS','BA','LA','CE','PR','ND','PM','SM','EU','GD','TB','DY','HO','ER','TM','YB','LU','HF','TA','W','RE','OS','IR','PT','AU','HG','TL','PB','BI','PO','AT','RN','FR','RA','AC','TH','PA','U','NP','PU','AM','CM','BK','CF','ES','FM','MD','NO','LR','RF','DB','SG','BH','HS','MT','DS','RG','CN','NH','FL','MC','LV','TS','OG']
def c(s):
    if s in e:
        return True
    return any(s.startswith(x) and c(s[len(x):]) for x in e)
print(['NO','YES'][c(input())])

strs = """Ac
Ag
Al
Am
Ar
As
At
Au
B
Ba
Be
Bh
Bi
Bk
Br
C
Ca
Cd
Ce
Cf
Cl
Cm
Cn
Co
Cr
Cs
Cu
Db
Ds
Dy
Er
Es
Eu
F
Fe
Fl
Fm
Fr
Ga
Gd
Ge
H
He
Hf
Hg
Ho
Hs
I
In
Ir
K
Kr
La
Li
Lr
Lu
Lv
Mc
Md
Mg
Mn
Mo
Mt
N
Na
Nb
Nd
Ne
Nh
Ni
No
Np
O
Og
Os
P
Pa
Pb
Pd
Pm
Po
Pr
Pt
Pu
Ra
Rb
Re
Rf
Rg
Rh
Rn
Ru
S
Sb
Sc
Se
Sg
Si
Sm
Sn
Sr
Ta
Tb
Tc
Te
Th
Ti
Tl
Tm
Ts
U
Ubb
Ubh
Ubn
Ubp
Ubq
Ubt
Ubu
Uue
V
W
Xe
Y
Yb
Zn
Zr"""
ele = strs.upper().split("\n")
# print(ele)
inp = input()
n = len(inp)
dp = [False] * (n+1)
dp[0] = True
for i in range(1, n+1):
  if dp[i-1] == True and inp[i-1:i] in ele:
    dp[i] = True
  elif i > 1 and dp[i-2] == True and inp[i-2:i] in ele:
    dp[i] = True
  elif i > 2 and dp[i-3] == True and inp[i-3:i] in ele:
    dp[i] = True
 
if dp[n]:
  print("YES")
else:
  print("NO")

w = input()
element = ['H', 'He', 'Li', 'Be', 'B', 'C', 'N', 'O', 'F', 'Ne', 'Na', 'Mg', 'Al', 'Si', 'P', 'S', 'Cl', 'Ar', 'K', 'Ca', 'Sc', 'Ti', 'V', 'Cr', 'Mn', 'Fe', 'Co', 'Ni', 'Cu', 'Zn', 'Ga', 'Ge', 'As', 'Se', 'Br', 'Kr', 'Rb', 'Sr', 'Y', 'Zr', 'Nb', 'Mo', 'Tc', 'Ru', 'Rh', 'Pd', 'Ag', 'Cd', 'In', 'Sn', 'Sb', 'Te', 'I', 'Xe', 'Cs', 'Ba', 'La', 'Ce', 'Pr', 'Nd', 'Pm', 'Sm', 'Eu', 'Gd', 'Tb', 'Dy', 'Ho', 'Er', 'Tm', 'Yb', 'Lu', 'Hf', 'Ta', 'W', 'Re', 'Os', 'Ir', 'Pt', 'Au', 'Hg', 'Tl', 'Pb', 'Bi', 'Po', 'At', 'Rn', 'Fr', 'Ra', 'Ac', 'Th', 'Pa', 'U', 'Np', 'Pu', 'Am', 'Cm', 'Bk', 'Cf', 'Es', 'Fm', 'Md', 'No', 'Lr', 'Rf', 'Db', 'Sg', 'Bh', 'Hs', 'Mt', 'Ds', 'Rg', 'Cn', 'Nh', 'Fl', 'Mc', 'Lv', 'Ts', 'Og']


mark = [0 for i in w]

for i in element:
    i = i.upper()
    if i in w:
        b = w.index(i)
        for idx,item in enumerate(i):
            mark[b+idx] = 1
#print(mark)

if 0 in mark:
    print('NO')
else:
    print('YES')

l=["H","HE","LI","BE","B","C","N","O","F","NE","NA","MG","AL","SI","P","S","CL","AR","K","CA","SC","TI","V","CR","MN","FE","CO","NI","CU","ZN","GA","GE","AS","SE","BR","KR","RB","SR","Y","ZR","NB","MO","TC","RU","RH","PD","AG","CD","LN","SN","SB","TE","I","XE","CS","BA","LA","CE","PR","ND","PM","SM","EU","GD","TB","DY","HO","ER","TM","YB","LU","HF","TA","W","RE","OS","IR","PT","AU","HG","TL","PB","BI","PO","AT","RN","FR","RA","AC","TH","PA","U","NP","PU","AM","CM","BK","CF","ES","FM","MD","NO","LR","RF","DB","SG","BH","HS","MT","DS","RG","CN","NH","FL","MC","LV","TS","OG"]
def dfs(s):
    if len(s)==0:
        return True
    elif len(s)==1:
        return (s[:1] in l)
    else:
        return (dfs(s[1:]) if s[:1] in l else False) or (dfs(s[2:]) if s[:2] in l else False)
                                                         
print("YES" if dfs(input()) else "NO")

l=["H","HE","LI","BE","B","C","N","O","F","NE","NA","MG","AL","SI","P","S","CL","AR","K","CA","SC","TI","V","CR","MN","FE","CO","NI","CU","ZN","GA","GE","AS","SE","BR","KR","RB","SR","Y","ZR","NB","MO","TC","RU","RH","PD","AG","CD","LN","SN","SB","TE","I","XE","CS","BA","LA","CE","PR","ND","PM","SM","EU","GD","TB","DY","HO","ER","TM","YB","LU","HF","TA","W","RE","OS","IR","PT","AU","HG","TL","PB","BI","PO","AT","RN","FR","RA","AC","TH","PA","U","NP","PU","AM","CM","BK","CF","ES","FM","MD","NO","LR","RF","DB","SG","BH","HS","MT","DS","RG","CN","NH","FL","MC","LV","TS","OG"]
def dfs(s):
    if len(s)==0:
        return True
    elif len(s)==1:
        return (s[:1] in l)
    else:
        return (dfs(s[1:]) if s[:1] in l else False) or (dfs(s[2:]) if s[:2] in l else False)
                                                         
print("YES" if dfs(input()) else "NO")

els = "H,He,Li,Be,B,C,N,O,F,Ne,Na,Mg,Al,Si,P,S,Cl,Ar,K,Ca,Sc,Ti,V,Cr,Mn,Fe,Co,Ni,Cu,Zn,Ga,Ge,As,Se,Br,Kr,Rb,Sr,Y,Zr,Nb,Mo,Tc,Ru,Rh,Pd,Ag,Cd,In,Sn,Sb,Te,I,Xe,Cs,Ba,La,Ce,Pr,Nd,Pm,Sm,Eu,Gd,Tb,Dy,Ho,Er,Tm,Yb,Lu,Hf,Ta,W,Re,Os,Ir,Pt,Au,Hg,Tl,Pb,Bi,Po,At,Rn,Fr,Ra,Ac,Th,Pa,U,Np,Pu,Am,Cm,Bk,Cf,Es,Fm,Md,No,Lr,Rf,Db,Sg,Bh,Hs,Mt,Ds,Rg,Cn,Nh,Fl,Mc,Lv,Ts,Og"

els = els.upper().split(',')

def check(s):
   for el in els:
      if s == el:
         return True
      match = False
      if len(el) <= len(s):
         match = True
         for x in range(len(el)):
            if s[x] != el[x]:
               match = False
               break
      if match:
         if check(s[len(el):]):
            return True
   return False

print("YES" if check(input()) else "NO")


# __template__
# # input() reads a whole line
# def getarr():
#    return(list(map(int, input().split())))

# def solve():
#    n = input()
#    s = input()
#    print(len(s.replace('UR','D').replace('RU','D')))
   
# # for tc in range(int(input())): solve()

# solve()


s='H,HE,LI,BE,B,C,N,O,F,NE,NA,MG,AL,SI,P,S,CL,AR,K,CA,SC,TI,V,CR,MN,FE,CO,NI,CU,ZN,GA,GE,AS,SE,BR,KR,RB,SR,Y,ZR,NB,MO,TC,RU,RH,PD,AG,CD,IN,SN,SB,TE,I,XE,CS,BA,LA,CE,PR,ND,PM,SM,EU,GD,TB,DY,HO,ER,TM,YB,LU,HF,TA,W,RE,OS,IR,PT,AU,HG,TL,PB,BI,PO,AT,RN,FR,RA,AC,TH,PA,U,NP,PU,AM,CM,BK,CF,ES,FM,MD,NO,LR,RF,DB,SG,BH,HS,MT,DS,RG,CN,NH,FL,MC,LV,TS,OG'.split(',')
x= input()
a=1
b=0
for i in range (len(x)):
    a,b= x[i] in s and a or x[i-1:i+1] in s and b,a
print(['NO', 'YES'][a])

E=["H","HE","LI","BE","B","C","N","O","F","NE","NA","MG","AL","SI","P","S","CL","AR","K","CA","SC","TI","V","CR","MN","FE","CO","NI","CU","ZN","GA","GE","AS","SE","BR","KR","RB","SR","Y","ZR","NB","MO","TC","RU","RH","PD","AG","CD","IN","SN","SB","TE","I","XE","CS","BA","LA","CE","PR","ND","PM","SM","EU","GD","TB","DY","HO","ER","TM","YB","LU","HF","TA","W","RE","OS","IR","PT","AU","HG","TL","PB","BI","PO","AT","RN","FR","RA","AC","TH","PA","U","NP","PU","AM","CM","BK","CF","ES","FM","MD","NO","LR","RF","DB","SG","BH","HS","MT","DS","RG","CN","NH","FL","MC","LV","TS","OG"]
def match(s):
    if s=="":
        return True
    if s[:1] in E:
        if match(s[1:]):
            return True
    if s[:2] in E:
        if match(s[2:]):
            return True
    return False
s=input()
if match(s):
    print("YES")
else:
    print("NO")

elements = [
	'AC','AG','AL','AM','AR','AS','AT','AU','B','BA','BE','BH','BI',
	'BK','BR','C','CA','CD','CE','CF','CL','CM','CN','CO','CR','CS',
	'CU','DB','DS','DY','ER','ES','EU','F','FE','FL','FM','FR','GA',
	'GD','GE','H','HE','HF','HG','HO','HS','I','IN','IR','K','KR',
	'LA','LI','LR','LU','LV','MC','MD','MG','MN','MO','MT','N','NA',
	'NB','ND','NE','NH','NI','NO','NP','O','OG','OS','P','PA','PB','PD',
	'PM','PO','PR','PT','PU','RA','RB','RE','RF','RG','RH','RN','RU','S',
	'SB','SC','SE','SG','SI','SM','SN','SR','TA','TB','TC','TE','TH','TI',
	'TL','TM','TS','U','V','W','XE','Y','YB','ZN','ZR']

def in_table(word):
	result = False
	for element in elements:
		if element == word:
			return True
		else:
			if len(word) > len(element) and word[:len(element)] == element:
				result = result or in_table(word[len(element):])

	return result

def main():
	word = input()
	if in_table(word):
		print('YES')
	else:
		print('NO')

def __starting_point():
	main()

__starting_point()

elements = [
	'AC','AG','AL','AM','AR','AS','AT','AU','B','BA','BE','BH','BI',
	'BK','BR','C','CA','CD','CE','CF','CL','CM','CN','CO','CR','CS',
	'CU','DB','DS','DY','ER','ES','EU','F','FE','FL','FM','FR','GA',
	'GD','GE','H','HE','HF','HG','HO','HS','I','IN','IR','K','KR',
	'LA','LI','LR','LU','LV','MC','MD','MG','MN','MO','MT','N','NA',
	'NB','ND','NE','NH','NI','NO','NP','O','OG','OS','P','PA','PB','PD',
	'PM','PO','PR','PT','PU','RA','RB','RE','RF','RG','RH','RN','RU','S',
	'SB','SC','SE','SG','SI','SM','SN','SR','TA','TB','TC','TE','TH','TI',
	'TL','TM','TS','U','V','W','XE','Y','YB','ZN','ZR']
 
def in_table(word):
	result = False
	for element in elements:
		if element == word:
			return True
		else:
			if len(word) > len(element) and word[:len(element)] == element:
				result = result or in_table(word[len(element):])
 
	return result
 
def main():
	word = input()
	if in_table(word):
		print('YES')
	else:
		print('NO')
 
def __starting_point():
	main()

__starting_point()

s = 'H,HE,LI,BE,B,C,N,O,F,NE,NA,MG,AL,SI,P,S,CL,AR,K,CA,SC,TI,V,CR,MN,FE,CO,NI,CU,ZN,GA,GE,AS,SE,BR,KR,RB,SR,Y,ZR,NB,MO,TC,RU,RH,PD,AG,CD,IN,SN,SB,TE,I,XE,CS,BA,LA,CE,PR,ND,PM,SM,EU,GD,TB,DY,HO,ER,TM,YB,LU,HF,TA,W,RE,OS,IR,PT,AU,HG,TL,PB,BI,PO,AT,RN,FR,RA,AC,TH,PA,U,NP,PU,AM,CM,BK,CF,ES,FM,MD,NO,LR,RF,DB,SG,BH,HS,MT,DS,RG,CN,NH,FL,MC,LV,TS,OG'.split(',')
x = input()
a = 1
b = 0
for i in range(len(x)):
	a, b = x[i] in s and a or x[i - 1:i + 1] in s and b, a
print(['NO', 'YES'][a])

els = ["AC","AG","AL","AM","AR","AS","AT","AU","B","BA","BE","BH","BI","BK","BR","C","CA","CD","CE","CF","CL","CM","CN","CO","CR","CS","CU","DB","DS","DY","ER","ES","EU","F","FE","FL","FM","FR","GA","GD","GE","H","HE","HF","HG","HO","HS","I","IN","IR","K","KR","LA","LI","LR","LU","LV","MC","MD","MG","MN","MO","MT","N","NA","NB","ND","NE","NH","NI","NO","NP","O","OG","OS","P","PA","PB","PD","PM","PO","PR","PT","PU","RA","RB","RE","RF","RG","RH","RN","RU","S","SB","SC","SE","SG","SI","SM","SN","SR","TA","TB","TC","TE","TH","TI","TL","TM","TS","U","V","W","XE","Y","YB","ZN","ZR"]
s = input()
 
def f(t):
    if t == "":
        return True
    for p in els:
        if t.startswith(p) and f(t[len(p):]):
            return True
    return False
    
if f(s):
    print("YES")
else:
    print("NO")

ele = 'H,HE,LI,BE,B,C,N,O,F,NE,NA,MG,AL,SI,P,S,CL,AR,K,CA,SC,TI,V,CR,MN,FE,CO,NI,CU,ZN,GA,GE,AS,SE,BR,KR,RB,SR,Y,ZR,NB,MO,TC,RU,RH,PD,AG,CD,IN,SN,SB,TE,I,XE,CS,BA,LA,CE,PR,ND,PM,SM,EU,GD,TB,DY,HO,ER,TM,YB,LU,HF,TA,W,RE,OS,IR,PT,AU,HG,TL,PB,BI,PO,AT,RN,FR,RA,AC,TH,PA,U,NP,PU,AM,CM,BK,CF,ES,FM,MD,NO,LR,RF,DB,SG,BH,HS,MT,DS,RG,CN,NH,FL,MC,LV,TS,OG'.split(',')
has = [input()]
ans = "NO"
while len(has) > 0:
    x = has.pop()
    if x == "":
        ans = "YES"
        break
    if x[0] in ele:
        has.append(x[1:])
    if len(x) > 1 and x[:2] in ele:
        has.append(x[2:])
print(ans)

s = ["AC", "AG", "AL", "AM", "AR", "AS", "AT", "AU", "BA", "BE", "BH", "BI",
     "BK", "BR", "B", "CA", "CD", "CE", "CF", "CL", "CM", "CN", "CO", "CR",
	 "CS", "CU", "C", "DB", "DS", "DY", "ER", "ES", "EU", "FE", "FL", "FM",
	 "FR", "F",  "GA", "GD", "GE", "HE", "HF", "HG", "HO", "HS", "H", "IN",
	 "IR", "I",  "KR", "K",  "LA", "LI", "LR", "LU", "LV", "MC", "MD", "MG",
	 "MN", "MO", "MT", "NA", "NB", "ND", "NE", "NH", "NI", "NO", "NP", "N",
	 "OG", "OS", "O", "PA", "PB", "PD", "PM", "PO", "PR", "PT", "PU", "P",
	 "RA", "RB", "RE", "RF", "RG", "RH", "RN", "RU", "SB", "SC", "SE", "SG",
	 "SI", "SM", "SN", "SR", "S", "TA", "TB", "TC", "TE", "TH", "TI", "TL",
	 "TM", "TS", "U", "V",  "W", "XE", "YB", "Y",  "ZN", "ZR"]
def DFS(a):
    if a is "":
        return "YES"
    for j in s:
        if (len(j)==1 and a[0]==j[0] and DFS(a[1:])=="YES") or (len(a)>=2 and len(j)==2 and a[0]==j[0] and a[1]==j[1] and DFS(a[2:])=="YES"):
            return "YES"
    return "NO"
 
ss = input()
print(DFS(ss))


s = 'H,HE,LI,BE,B,C,N,O,F,NE,NA,MG,AL,SI,P,S,CL,AR,K,CA,SC,TI,V,CR,MN,FE,CO,NI,CU,ZN,GA,GE,AS,SE,BR,KR,RB,SR,Y,ZR,NB,MO,TC,RU,RH,PD,AG,CD,IN,SN,SB,TE,I,XE,CS,BA,LA,CE,PR,ND,PM,SM,EU,GD,TB,DY,HO,ER,TM,YB,LU,HF,TA,W,RE,OS,IR,PT,AU,HG,TL,PB,BI,PO,AT,RN,FR,RA,AC,TH,PA,U,NP,PU,AM,CM,BK,CF,ES,FM,MD,NO,LR,RF,DB,SG,BH,HS,MT,DS,RG,CN,NH,FL,MC,LV,TS,OG'.split(
    ',')
x = input()
count1, count2 = 1, 0
for i in range(len(x)):
    count1, count2 = x[i] in s and count1 or x[i - 1:i + 1] in s and count2, count1
print(['NO', 'YES'][count1])


ele = ["H", "He", "Li", "Be", "B", "C", "N", "O", "F", "Ne", "Na", "Mg", "Al", "Si", "P", "S", "Cl", "Ar,A", "K", "Ca", "Sc", "Ti", "V", "Cr", "Mn", "Fe", "Co", "Ni", "Cu", "Zn", "Ga", "Ge", "As", "Se", "Br", "Kr", "Rb", "Sr", "Y", "Zr", "Nb", "Mo", "Tc", "Ru", "Rh", "Pd", "Ag", "Cd", "In", "Sn", "Sb", "Te", "I", "Xe", "Cs", "Ba", "La", "Ce", "Pr", "Nd", "Pm", "Sm", "Eu", "Gd", "Tb", "Dy", "Ho", "Er", "Tm", "Yb", "Lu", "Hf", "Ta", "W", "Re", "Os", "Ir", "Pt", "Au", "Hg", "Tl", "Pb", "Bi", "Po", "At", "Rn", "Fr", "Ra", "Ac", "Th", "Pa", "U", "Np", "Pu", "Am", "Cm","Bk","Cf","Es","Fm","Md","No","Lr","Rf","Db","Sg","Bh","Hs","Mt","Ds","Rg","Cn","Nh","Fl","Mc","Lv","Ts","Og"]
for i in range(len(ele)):
    if len(ele[i]) == 2:
        ele[i] = ele[i][0] + chr(ord(ele[i][1]) - 32)
ele = ["AC","AG","AL","AM","AR","AS","AT","AU","B","BA","BE","BH","BI","BK","BR","C","CA","CD","CE","CF","CL","CM","CN","CO","CR","CS","CU","DB","DS","DY","ER","ES","EU","F","FE","FL","FM","FR","GA","GD","GE","H","HE","HF","HG","HO","HS","I","IN","IR","K","KR","LA","LI","LR","LU","LV","MC","MD","MG","MN","MO","MT","N","NA","NB","ND","NE","NH","NI","NO","NP","O","OG","OS","P","PA","PB","PD","PM","PO","PR","PT","PU","RA","RB","RE","RF","RG","RH","RN","RU","S","SB","SC","SE","SG","SI","SM","SN","SR","TA","TB","TC","TE","TH","TI","TL","TM","TS","U","V","W","XE","Y","YB","ZN","ZR"]
        

s = input().strip()

d = [False] * len(s) * 2
d[0] = True

for i in range(len(s)):
    if d[i]:
        #print(i)
        if s[i] > 'Z':
            while True:
                s += '1'
        for e in ele:
            if s[i] == e:
                d[i + 1] = True
            elif s[i:i+2] == e:
                d[i + 2] = True
if d[len(s)]:
    print('YES')
else:
    print('NO')

e=input()
d=0
def f(e):
    arr= ['H','HE','LI','BE','B','C','N','O','F','NE','NA','MG','AL','SI','P','S','CL','AR','K','CA','SC','TI','V','CR','MN','FE','CO','NI','CU','ZN','GA','GE','AS','SE','BR','KR','RB','SR','Y','ZR','NB','MO','TC','RU','RH','PD','AG','CD','IN','SN','SB','TE','I','XE','CS','BA','LA','CE','PR','ND','PM','SM','EU','GD','TB','DY','HO','ER','TM','YB','LU','HF','TA','W','RE','OS','IR','PT','AU','HG','TL','PB','BI','PO','AT','RN','FR','RA','AC','TH','PA','U','NP','PU','AM','CM','BK','CF','ES','FM','MD','NO','LR','RF','DB','SG','BH','HS','MT','DS','RG','CN','NH','FL','MC','LV','TS','OG']
    if(e==''):
        return True
    if(e[0] in arr):
        if(f(e[1:]) is True):
           return True
    if(e[0:2] in arr):
        if(f(e[2:])is True):
           return True
    return False
if(f(e) is True):
    print("YES")
else:
    print("NO")


s = """

Hydrogen	H	Niobium	Nb	Thallium	Tl
Helium	He	Molybdenum	Mo	Lead	Pb
Lithium	Li	Technetium	Tc	Bismuth	Bi
Beryllium	Be	Ruthenium	Ru	Polonium	Po
Boron	B	Rhodium	Rh	Astatine	At
Carbon	C	Palladium	Pd	Radon	Rn
Nitrogen	N	Silver	Ag	Francium	Fr
Oxygen	O	Cadmium	Cd	Radium	Ra
Fluorine	F	Indium	In	Actinium	Ac
Neon	Ne	Tin	Sn	Thorium	Th
Sodium	Na	Antimony	Sb	Protactinium	Pa
Magnesium	Mg	Tellurium	Te	Uranium	U
Aluminum	Al	Iodine	I	Neptunium	Np
Silicon	Si	Xenon	Xe	Plutonium	Pu
Phosphorus	P	Cesium	Cs	Americium	Am
Sulfur	S	Barium	Ba	Curium	Cm
Chlorine	Cl	Lanthanum	La	Berkelium	Bk
Argon	Ar	Cerium	Ce	Californium	Cf
Potassium	K	Praseodymium	Pr	Einsteinium	Es
Calcium	Ca	Neodymium	Nd	Fermium	Fm
Scandium	Sc	Promethium	Pm	Mendelevium	Md
Titanium	Ti	Samarium	Sm	Nobelium	No
Vanadium	V	Europium	Eu	Lawrencium	Lr
Chromium	Cr	Gadolinium	Gd	Rutherfordium	Rf
Manganese	Mn	Terbium	Tb	Dubnium	Db
Iron	Fe	Dysprosium	Dy	Seaborgium	Sg
Cobalt	Co	Holmium	Ho	Bohrium	Bh
Nickel	Ni	Erbium	Er	Hassium	Hs
Copper	Cu	Thulium	Tm	Meitnerium	Mt
Zinc	Zn	Ytterbium	Yb	Darmstadtium	Ds
Gallium	Ga	Lutetium	Lu	Roentgenium	Rg
Germanium	Ge	Hafnium	Hf	Copernicium	Cn
Arsenic	As	Tantalum	Ta	Nihonium	Nh
Selenium	Se	Tungsten	W	Flerovium	Fl
Bromine	Br	Rhenium	Re	Moscovium	Mc
Krypton	Kr	Osmium	Os	Livermorium	Lv
Rubidium	Rb	Iridium	Ir	Tennessine	Ts
Strontium	Sr	Platinum	Pt	Oganesson	Og
Yttrium	Y	Gold	Au
Zirconium	Zr	Mercury	Hg
"""
elems = []
for idx, token in enumerate(s.split()):
  if idx % 2 == 1:
    elems.append(token.upper())


def check(s):
  if not s:
    return True
  for idx in range(len(s)):
    if s[idx:] in elems and check(s[:idx]):
      return True
  return False

s = input()
if check(s):
  print("YES")
else:
  print("NO")


s = 'H,HE,LI,BE,B,C,N,O,F,NE,NA,MG,AL,SI,P,S,CL,AR,K,CA,SC,TI,V,CR,MN,FE,CO,NI,CU,ZN,GA,GE,AS,SE,BR,KR,RB,SR,Y,ZR,NB,MO,TC,RU,RH,PD,AG,CD,IN,SN,SB,TE,I,XE,CS,BA,LA,CE,PR,ND,PM,SM,EU,GD,TB,DY,HO,ER,TM,YB,LU,HF,TA,W,RE,OS,IR,PT,AU,HG,TL,PB,BI,PO,AT,RN,FR,RA,AC,TH,PA,U,NP,PU,AM,CM,BK,CF,ES,FM,MD,NO,LR,RF,DB,SG,BH,HS,MT,DS,RG,CN,NH,FL,MC,LV,TS,OG'.split(
    ',')
x = input()
count1, count2 = 1, 0
for i in range(len(x)):
    count1, count2 = x[i] in s and count1 or x[i - 1:i + 1] in s and count2, count1
print(['NO', 'YES'][count1])

E = set(('H', 'HE', 'LI', 'BE', 'B', 'C', 'N', 'O', 'F', 'NE', 'NA', 'MG', 'AL', 'SI', 'P', 'S', 'CL', 'AR', 'K', 'CA', 'SC', 'TI', 'V', 'CR', 'MN', 'FE', 'CO', 'NI', 'CU', 'ZN', 'GA', 'GE', 'AS', 'SE', 'BR', 'KR', 'RB', 'SR', 'Y', 'ZR', 'NB', 'MO', 'TC', 'RU', 'RH', 'PD', 'AG', 'CD', 'IN', 'SN', 'SB', 'TE', 'I', 'XE', 'CS', 'BA', 'LA', 'CE', 'PR', 'ND', 'PM', 'SM', 'EU', 'GD', 'TB', 'DY', 'HO', 'ER', 'TM', 'YB', 'LU', 'HF', 'TA', 'W', 'RE', 'OS', 'IR', 'PT', 'AU', 'HG', 'TL', 'PB', 'BI', 'PO', 'AT', 'RN', 'FR', 'RA', 'AC', 'TH', 'PA', 'U', 'NP', 'PU', 'AM', 'CM', 'BK', 'CF', 'ES', 'FM', 'MD', 'NO', 'LR', 'RF', 'DB', 'SG', 'BH', 'HS', 'MT', 'DS', 'RG', 'CN', 'NH', 'FL', 'MC', 'LV', 'TS', 'OG'))

q = input()
n = len(q)
ok = [0] * (n + 1)
ok[0] = 1
for i in range(n):
    if q[i] in E:
        ok[i + 1] = ok[i]
    if i > 0 and q[i - 1:i + 1] in E:
        ok[i + 1] = max(ok[i + 1], ok[i - 1])
print('YES' if ok[n] else 'NO')


import re
if re.match( r'^(H|HE|LI|BE|B|C|N|O|F|NE|NA|MG|AL|SI|P|S|CL|AR|K|CA|SC|TI|V|CR|MN|FE|CO|NI|CU|ZN|GA|GE|AS|SE|BR|KR|RB|SR|Y|ZR|NB|MO|TC|RU|RH|PD|AG|CD|IN|SN|SB|TE|I|XE|CS|BA|LA|CE|PR|ND|PM|SM|EU|GD|TB|DY|HO|ER|TM|YB|LU|HF|TA|W|RE|OS|IR|PT|AU|HG|TL|PB|BI|PO|AT|RN|FR|RA|AC|TH|PA|U|NP|PU|AM|CM|BK|CF|ES|FM|MD|NO|LR|RF|DB|SG|BH|HS|MT|DS|RG|CN|NH|FL|MC|LV|TS|OG)*$', input()):
    print("YES")
else:
    print("NO")

elements = set([
	'Ac','Ag','Al','Am','Ar','As','At','Au','B','Ba','Be','Bh','Bi','Bk','Br','C',
	'Ca','Cd','Ce','Cf','Cl','Cm','Cn','Co','Cr','Cs','Cu','Db','Ds','Dy','Er',
	'Es','Eu','F','Fe','Fl','Fm','Fr','Ga','Gd','Ge','H','He','Hf','Hg','Ho','Hs',
	'I','In','Ir','K','Kr','La','Li','Lr','Lu','Lv','Mc','Md','Mg','Mn','Mo','Mt',
	'N','Na','Nb','Nd','Ne','Nh','Ni','No','Np','O','Og','Os','P','Pa','Pb','Pd',
	'Pm','Po','Pr','Pt','Pu','Ra','Rb','Re','Rf','Rg','Rh','Rn','Ru','S','Sb',
	'Sc','Se','Sg','Si','Sm','Sn','Sr','Ta','Tb','Tc','Te','Th','Ti','Tl','Tm',
	'Ts','U','V','W','Xe','Y','Yb','Zn','Zr'
])
 
elem = list(map(lambda x: x.upper(), elements))
 
def find(s):
	if s == "": 
		return True
 
	if s[0] in elem:
		if find(s[1:]):
			return True
 
	if s[0:2] in elem:
		if find(s[2:]):
			return True
	return False

if find(input()):
	print("YES")
else:
	print("NO")

E = set(('H', 'HE', 'LI', 'BE', 'B', 'C', 'N', 'O', 'F', 'NE', 'NA', 'MG', 'AL', 'SI', 'P', 'S', 'CL', 'AR', 'K', 'CA', 'SC', 'TI', 'V', 'CR', 'MN', 'FE', 'CO', 'NI', 'CU', 'ZN', 'GA', 'GE', 'AS', 'SE', 'BR', 'KR', 'RB', 'SR', 'Y', 'ZR', 'NB', 'MO', 'TC', 'RU', 'RH', 'PD', 'AG', 'CD', 'IN', 'SN', 'SB', 'TE', 'I', 'XE', 'CS', 'BA', 'LA', 'CE', 'PR', 'ND', 'PM', 'SM', 'EU', 'GD', 'TB', 'DY', 'HO', 'ER', 'TM', 'YB', 'LU', 'HF', 'TA', 'W', 'RE', 'OS', 'IR', 'PT', 'AU', 'HG', 'TL', 'PB', 'BI', 'PO', 'AT', 'RN', 'FR', 'RA', 'AC', 'TH', 'PA', 'U', 'NP', 'PU', 'AM', 'CM', 'BK', 'CF', 'ES', 'FM', 'MD', 'NO', 'LR', 'RF', 'DB', 'SG', 'BH', 'HS', 'MT', 'DS', 'RG', 'CN', 'NH', 'FL', 'MC', 'LV', 'TS', 'OG'))

q = input()
n = len(q)
ok = [0] * (n + 1)
ok[0] = 1
for i in range(n):
    if q[i] in E:
        ok[i + 1] = ok[i]
    if i > 0 and q[i - 1:i + 1] in E:
        ok[i + 1] = max(ok[i + 1], ok[i - 1])
print('YES' if ok[n] else 'NO')

import os
import sys
from io import BytesIO, IOBase
import heapq as h 
from bisect import bisect_left

from types import GeneratorType
BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0
 
    def __init__(self, file):
        import os
        self.os = os
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
 
    def read(self):
        while True:
            b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
 
    def readline(self):
        while self.newlines == 0:
            b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
 
    def flush(self):
        if self.writable:
            self.os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
 
 
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
 
 
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
 
import time
start_time = time.time()

import collections as col
import math, string
from functools import reduce

def getInts():
    return [int(s) for s in input().split()]

def getInt():
    return int(input())

def getStrs():
    return [s for s in input().split()]

def getStr():
    return input()

def listStr():
    return list(input())

MOD = 10**9+7

"""

"""
def solve():
    els = ["H","He","Li","Be","B","C","N","O","F","Ne","Na","Mg","Al","Si","P","S","Cl","Ar","K","Ca","Sc","Ti","V","Cr","Mn","Fe","Co","Ni","Cu","Zn","Ga","Ge","As","Se","Br","Kr","Rb","Sr","Y","Zr","Nb","Mo","Tc","Ru","Rh","Pd","Ag","Cd","In","Sn","Sb","Te","I","Xe","Cs","Ba","La","Ce","Pr","Nd","Pm","Sm","Eu","Gd","Tb","Dy","Ho","Er","Tm","Yb","Lu","Hf","Ta","W","Re","Os","Ir","Pt","Au","Hg","Tl","Pb","Bi","Po","At","Rn","Fr","Ra","Ac","Th","Pa","U","Np","Pu","Am","Cm","Bk","Cf","Es","Fm","Md","No","Lr","Rf","Db","Sg","Bh","Hs","Mt","Ds","Rg","Cn","Nh","Fl","Mc","Lv","Ts","Og"]
    for i, el in enumerate(els):
        els[i] = el.upper()
    dp = [True]
    S = getStr()
    for i in range(len(S)):
        if len(dp) == 1:
            dp.append(dp[-1] and (S[i].upper() in els))
        else:
            dp.append((dp[-1] and S[i].upper() in els) or (dp[-2] and S[i-1:i+1].upper() in els))
    return "YES" if dp[len(S)] else "NO"
    
    
#for _ in range(getInt()):    
print(solve())