As it's the first of April, Heidi is suspecting that the news she reads today are fake, and she does not want to look silly in front of all the contestants. She knows that a newspiece is fake if it contains heidi as a subsequence. Help Heidi assess whether the given piece is true, but please be discreet about it...


-----Input-----

The first and only line of input contains a single nonempty string s of length at most 1000 composed of lowercase letters (a-z).


-----Output-----

Output YES if the string s contains heidi as a subsequence and NO otherwise.


-----Examples-----
Input
abcheaibcdi

Output
YES
Input
hiedi

Output
NO


-----Note-----

A string s contains another string p as a subsequence if it is possible to delete some characters from s and obtain p.

Difficulty: EASY

Solutions:
s = input()
patern = 'heidi'
prev = 0
for c in patern:
	ok = False
	for i in range(prev, len(s)):
		prev += 1
		if s[i] == c:
			ok = True
			break
	if not ok:
		print('NO\n')
		exit()
print('YES\n')


s = input()
i = 0
j = 0
s1 = 'heidi'
while i < len(s):
	if s1[j] == s[i]:
		j += 1
	i += 1
	if j == 5:
		break
if j >= 5:
	print('YES')
else:
	print('NO')


N = str(input())
S = ''
a = 0
b = 0
c = 0
d = 0
for i in range(len(N)):
	if N[i] == 'h':
		S = S + N[i]
		a = i
		break
for j in range(a + 1, len(N)):
	if N[j] == 'e':
		S = S + N[j]
		b = j
		break
for k in range(b + 1, len(N)):
	if N[k] == 'i':
		S = S + N[k]
		c = k
		break
for l in range(c + 1, len(N)):
	if N[l] == 'd':
		S = S + N[l]
		d = l
		break
for m in range(d + 1, len(N)):
	if N[m] == 'i':
		S = S + N[m]
		break
if S == 'heidi':
	print('YES')
else:
	print('NO')


s = input()
a = 0
pat = 'heidi'
for i in s:
	if i == pat[a]:
		a += 1
		if a == 5:
			break
print('YES') if a == 5 else print('NO')


_ = 'heidi'
n = input()
__ = 0
while True:
	if n[__] not in _:
		n = n.replace(n[__], '')
	else:
		__ += 1
	if __ >= len(n):
		break
DFX = 0
for i in range(len(n)):
	if n[i] == 'heidi'[DFX]:
		DFX += 1
		if DFX == 5:
			print('YES')
			exit(0)
print('NO')


h = []
s = input()
s = s + '0'
k = len(s)
x = False
for i in range(k):
	if s[i] == 'h':
		h.append('h')
	elif s[i] == 'e':
		for j in range(len(h)):
			if len(h[j]) == 1:
				h[j] = h[j] + 'e'
	elif s[i] == 'i':
		for j in range(len(h)):
			if len(h[j]) == 2 or len(h[j]) == 4:
				h[j] = h[j] + 'i'
	elif s[i] == 'd':
		for j in range(len(h)):
			if len(h[j]) == 3:
				h[j] = h[j] + 'd'
	if 'heidi' in h and x == False:
		print('YES')
		x = True
if x == False:
	print('NO')


s = input()
i1 = s.find('h')
if i1 >= 0:
	i2 = s[i1:].find('e')
	if i2 >= 0:
		i3 = s[i2 + i1:].find('i')
		if i3 >= 0:
			i4 = s[i3 + i2 + i1:].find('d')
			if i4 >= 0:
				i5 = s[i4 + i3 + i2 + i1:].find('i')
				if i5 >= 0:
					print('YES')
				else:
					print('NO')
			else:
				print('NO')
		else:
			print('NO')
	else:
		print('NO')
else:
	print('NO')


n = input()
s = 'heidi'
i = 0
flag = 0
for j in n:
	if j == s[i]:
		i += 1
		flag = 1
	if len(s) == i:
		break
if flag == 1 and i == len(s):
	print('YES')
else:
	print('NO')


s = list(input())
t = list('heidi')
ls = []
for c in s:
	if c == t[len(ls)]:
		ls.append(c)
	if len(ls) == len(t):
		break
if len(ls) == len(t):
	print('YES')
else:
	print('NO')


str = str(input())
j = 0
s = 'heidi#'
for i in str:
	if i == s[j]:
		j += 1
print('YES' if j == 5 else 'NO')


x = [i for i in input()]

def charpos(c1, arr):
	for i in range(len(arr)):
		if arr[i] == c1:
			return i
	return -1
temp = 0
result = True
for i in 'heidi':
	temp = charpos(i, x)
	x = x[temp:]
	if temp == -1:
		result = False
		break
if result:
	print('YES')
else:
	print('NO')


string = input()
checker = 'heidi'
counter = 0
for i in string:
	if checker[counter] == i:
		counter += 1
		if counter == 5:
			break
if counter == 5:
	print('YES')
else:
	print('NO')


s = input()
b = ['h', 'e', 'i', 'd', 'i']
i = 0
for j in s:
	if j == b[i]:
		i += 1
		if i == 5:
			break
if i == 5:
	print('YES')
else:
	print('NO')


s = input()
k = 0
for i in range(len(s)):
	if k == 0 and s[i] == 'h':
		k += 1
	elif k == 1 and s[i] == 'e':
		k += 1
	elif k == 2 and s[i] == 'i':
		k += 1
	elif k == 3 and s[i] == 'd':
		k += 1
	elif k == 4 and s[i] == 'i':
		k += 1
if k == 5:
	print('YES')
else:
	print('NO')


str = input()
str2 = 'heidi'
l1 = len(str2)
l2 = len(str)
j = 0
res = 0
for i in range(l2):
	if j < 5 and str[i] == str2[j]:
		res += 1
		j += 1
if res == 5:
	print('YES')
else:
	print('NO')


s = input()
n = 'heidi'
c = 0
for i in range(len(s)):
	if s[i] == n[c]:
		c += 1
		if c == len(n):
			print('YES')
			exit(0)
print('NO')


(index, Word) = (0, 'heidi')
for i in input():
	index += 1 if i == Word[index] else 0
	if index == 5:
		print('YES')
		exit()
print('NO')


string = input()
sample = 'heidi'
w = ''
j = 0
for i in range(len(string)):
	if j < 5 and string[i] == sample[j]:
		w += string[i]
		j += 1
if w == sample:
	print('YES')
else:
	print('NO')


x = input()
name = 'heidi'
len_x = len(x)
len_name = len(name)
n = 0
r = ''
for i in x:
	if i == name[n:n + 1]:
		n += 1
	if n == len_name:
		r = 'YES'
		break
	elif i == x[len_x - 1]:
		r = 'NO'
print(r)


string = input()
count = 0
value = ['h', 'e', 'i', 'd', 'i']
position = 0
y = 0
for i in range(0, len(string)):
	for x in range(y, len(value)):
		if string[i] == value[count]:
			count = count + 1
			y = y + 1
if count == 5:
	print('YES')
else:
	print('NO')


n = input()
a = 'heidi'
count = i = 0
while i < len(n):
	if a[count] == n[i]:
		count += 1
	i += 1
	if count == 5:
		break
if count == 5 and i <= len(n):
	print('YES')
else:
	print('NO')


string = input()
x = 0
while x < len(string) and string[x] != 'h':
	x += 1
while x < len(string) and string[x] != 'e':
	x += 1
while x < len(string) and string[x] != 'i':
	x += 1
while x < len(string) and string[x] != 'd':
	x += 1
while x < len(string) and string[x] != 'i':
	x += 1
if x >= len(string):
	print('NO')
else:
	print('YES')


li = list(input())

def f(n, s):
	global li
	while True:
		if li[n] != s:
			li.pop(n)
		else:
			break
try:
	f(0, 'h')
	f(1, 'e')
	f(2, 'i')
	f(3, 'd')
	f(4, 'i')
except:
	print('NO')
else:
	print('YES')


(s, c) = ('heidi', 0)
for i in input():
	if i == s[c]:
		c += 1
	if c == 5:
		break
print('YES' if c == 5 else 'NO')


s = input()
s = list(s)
l = ['h', 'e', 'i', 'd', 'i']
j = 0
for i in s:
	if i == l[j]:
		j = j + 1
		if j > 4:
			print('YES')
			break
if j <= 4:
	print('NO')


(b, c, f, a) = ('heidi', 0, 0, input())
if len(a) > 5:
	for x in range(len(a)):
		if a[x] == b[c]:
			c += 1
		if c == 5:
			f = 1
			break
if f == 1:
	print('YES')
else:
	print('NO')


a = [x for x in list(input()) if x in 'heid']
if 'h' in a:
	first = a.index('h')
	if 'e' in a[first:]:
		second = first + a[first:].index('e')
		if 'i' in a[second:]:
			third = second + a[second:].index('i')
			if 'd' in a[third:]:
				fourth = third + a[third:].index('d')
				if 'i' in a[fourth:]:
					print('YES')
				else:
					print('NO')
			else:
				print('NO')
		else:
			print('NO')
	else:
		print('NO')
else:
	print('NO')


s = input()

def stringAnalzer(string):
	h = 'heidi'
	index = 0
	for x in string:
		if x == h[index]:
			index += 1
		if index == 5:
			return 'YES'
	return 'NO'
print(stringAnalzer(s))


n = input()
lookingfor = 'heidi'
count = 0
for i in 'heidi':
	index = n.find(i)
	n = n[index:]
	if index != -1:
		count += 1
if count == 5:
	print('YES')
else:
	print('NO')


s = input()
p = ['h', 'e', 'i', 'd', 'i', '']
for x in range(len(s)):
	if s[x] == p[0]:
		p.pop(0)
if len(p) == 1:
	print('YES')
else:
	print('NO')


def issubsequence(s1, s2):
	m = len(s1)
	n = len(s2)
	i = 0
	j = 0
	while i < m and j < n:
		if s1[i] == s2[j]:
			i = i + 1
		j = j + 1
	return i == m
s1 = 'heidi'
s2 = input()
if issubsequence(s1, s2):
	print('YES')
else:
	print('NO')


inp = input()
result = 0
ans = 1
for alp in 'heidi':
	inp = inp[result:]
	result = inp.find(alp)
	if result == -1:
		ans = 0
		break
if ans:
	print('YES')
else:
	print('NO')


x = 'heidi'
s = input()
index = 0
for i in range(len(s)):
	if s[i] == x[index]:
		index += 1
	if index == 5:
		break
if index == 5:
	print('YES')
else:
	print('NO')


n = ' '.join(input()).split()
s = []
for i in range(0, len(n)):
	if n[i] == 'h' or n[i] == 'e' or n[i] == 'i' or (n[i] == 'd'):
		if n[i] == 'i':
			if s.count('i') < 1:
				if s.count('h') > 0 and s.count('e') > 0:
					s.append(n[i])
			elif 2 > s.count('i') > 0:
				if s.count('h') > 0 and s.count('e') > 0 and (s.count('d') > 0):
					s.append(n[i])
		elif n[i] == 'h':
			if s.count('h') < 1:
				s.append(n[i])
		elif n[i] == 'e':
			if s.count('e') < 1:
				if s.count('h') > 0:
					s.append(n[i])
		elif n[i] == 'd':
			if s.count('d') < 1:
				if s.count('i') > 0 and s.count('i') < 2 and (s.count('h') > 0) and (s.count('e') > 0):
					s.append(n[i])
s = str(s)
s = s.replace('[', '')
s = s.replace(']', '')
s = s.replace(',', '')
s = s.replace("'", '')
s = s.replace(' ', '')
if s.count('heidi') > 0:
	print('YES')
else:
	print('NO')


ch = input()
t = False
if ch.find('h') >= 0:
	ch = ch[ch.index('h'):]
	if ch.find('e') >= 0:
		ch = ch[ch.index('e'):]
		if ch.find('i') >= 0:
			ch = ch[ch.index('i'):]
			if ch.find('d') >= 0:
				ch = ch[ch.index('d'):]
				if ch.find('i') >= 0:
					t = True
if t:
	print('YES')
else:
	print('NO')


s = input()
l = ['h', 'e', 'i', 'd', 'i']
m = 0
c = 0
for i in range(5):
	flag = 0
	for j in range(len(s) - c):
		if flag == 0:
			if l[i] == s[j + c]:
				c += j + 1
				flag = 1
				m += 1
if m == 5:
	print('YES')
else:
	print('NO')


s = input()
x = 'heidi'
j = 0
for i in s:
	if i == x[j]:
		j += 1
	if j == 5:
		print('YES')
		exit()
print('NO')


x = input()
y = 'heidi'
z = ''
j = 0
for i in y:
	t = True
	while j < len(x) and t:
		if x[j] == i:
			z += i
			t = False
		j += 1
else:
	if y == z:
		print('YES')
	else:
		print('NO')


s = str(input())
l = ['h', 'e', 'i', 'd', 'i']
ans = 0
for i in range(5):
	if str(l[i]) not in s:
		print('NO')
		ans = 1
		break
	else:
		x = s.find(l[i])
		s = s[x:]
if ans == 0:
	print('YES')


import sys

def solve():
	s = input()
	if is_subst(s, 'heidi'):
		print('YES')
	else:
		print('NO')

def is_subst(s, t):
	tlen = len(t)
	slen = len(s)
	cnt = 0
	l = 0
	for i in range(tlen):
		for j in range(l, slen):
			if t[i] == s[j]:
				l = j + 1
				cnt += 1
				break
		else:
			l = slen
	return cnt == tlen

def __starting_point():
	solve()
__starting_point()


s = input()
n = len(s)
a = 'heidi'
m = len(a)
i = 0
j = 0
if a == s:
	print('NO')
else:
	while i < n and j < m:
		if s[i] == a[j]:
			j += 1
		i += 1
	if j == len(a):
		print('YES')
	else:
		print('NO')


import math, itertools, fractions, heapq, collections, bisect, sys, queue, copy
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def LS():
	return sys.stdin.readline().split()

def S():
	return input()

def main():
	s = S()
	ind = 0
	y = 'heidi'
	for x in s:
		if x == y[ind]:
			ind += 1
		if ind == 5:
			return 'YES'
	return 'NO'
print(main())


s = input().strip()
p = 'heidi'

def subseq(p, s):
	i = 0
	j = 0
	n = len(s)
	while j < 5 and i < n:
		if p[j] == s[i]:
			j += 1
		i += 1
	return j == 5
if subseq(p, s):
	print('YES')
else:
	print('NO')


import sys
S = input()
if S.find('h') >= 0:
	S = S[S.find('h'):]
	if S.find('e') >= 0:
		S = S[S.find('e'):]
		if S.find('i') >= 0:
			S = S[S.find('i'):]
			if S.find('d') >= 0:
				S = S[S.find('d'):]
				if S.find('i') >= 0:
					print('YES')
					sys.exit()
print('NO')


n = input()
l = 'heidi'
ans = 'YES'
j = 0
for i in n:
	if l[j] == i:
		j += 1
	if j == 5:
		break
if j != 5:
	print('NO')
else:
	print(ans)


def fake(string):
	value = 'heidi'
	i = 0
	j = 0
	while i < len(string) and j < len(value):
		if string[i] == value[j]:
			i = i + 1
			j = j + 1
		else:
			i = i + 1
	return j == len(value)
string = input()
if fake(string):
	print('YES')
else:
	print('NO')


import sys
s = input()
a = s.find('h')
if a != -1:
	s = s[a:]
	a = s.find('e')
	if a != -1:
		s = s[a:]
		a = s.find('i')
		if a != -1:
			s = s[a:]
			a = s.find('d')
			if a != -1:
				s = s[a:]
				a = s.find('i')
				if a != -1:
					print('YES')
					return
print('NO')


s = input()
k = 0
if 'h' in s:
	s = s[s.index('h'):]
	k += 1
if 'e' in s:
	s = s[s.index('e'):]
	k += 1
if 'i' in s:
	s = s[s.index('i'):]
	k += 1
if 'd' in s:
	s = s[s.index('d'):]
	k += 1
if 'i' in s:
	s = s[s.index('i'):]
	k += 1
if k == 5:
	print('YES')
else:
	print('NO')


st = input()
l = len(st)
for a in range(l):
	if st[a] == 'h':
		for b in range(a + 1, l):
			if st[b] == 'e':
				for c in range(b + 1, l):
					if st[c] == 'i':
						for d in range(c + 1, l):
							if st[d] == 'd':
								for e in range(d + 1, l):
									if st[e] == 'i':
										print('YES')
										exit()
								break
						break
				break
		break
print('NO')


s = input()
h = 'heidi'
j = 0
for i in s:
	if i == h[j]:
		j += 1
	if j == 5:
		break
print('YES' if j == 5 else 'NO')


m = 'heidi'

def chatRoom():
	x = 0
	s = input()
	for i in range(len(s)):
		if s[i] == m[x]:
			x += 1
		if x == 5:
			return 'YES'
	return 'NO'
print(chatRoom())


target = 'heidi'
i = 0
for x in input():
	if x == target[i]:
		i += 1
		if i == len(target):
			break
if i == len(target):
	print('YES')
else:
	print('NO')


x = input()
s = 'heidi'
m = 0
for i in x:
	if i == s[m]:
		m += 1
	if m == 5:
		break
if m == 5:
	print('YES')
else:
	print('NO')


S = input()
S = str(S)
P = 'heidi'
j = 0
for i in range(0, len(S)):
	if j < 5 and S[i] == P[j]:
		j += 1
if j == 5:
	print('YES')
else:
	print('NO')


string = input()
targetString = 'heidi'
targetCharPyindex = 0
finishTargetString = ''
for char in string:
	if char == targetString[targetCharPyindex]:
		finishTargetString += targetString[targetCharPyindex]
		targetCharPyindex += 1
	if targetCharPyindex == len(targetString):
		break
if finishTargetString == targetString:
	print('YES')
else:
	print('NO')


input_list = list(input())
flag = 0
for a in input_list:
	if a == 'h' and flag == 0:
		flag = 1
	elif a == 'e' and flag == 1:
		flag = 2
	elif a == 'i' and flag == 2:
		flag = 3
	elif a == 'd' and flag == 3:
		flag = 4
	elif a == 'i' and flag == 4:
		flag = 5
if flag == 5:
	print('YES')
else:
	print('NO')


def check():
	s = input()
	li = []
	for i in range(len(s)):
		if s[i] == 'h' and len(li) == 0:
			li.append('h')
		if s[i] == 'e' and len(li) == 1:
			li.append('e')
		if s[i] == 'i' and len(li) == 2:
			li.append('i')
		if s[i] == 'd' and len(li) == 3:
			li.append('d')
		if s[i] == 'i' and len(li) == 4:
			li.append('i')
			print('YES')
			return
	print('NO')
check()


j = 0
a = 'heidi!'
for i in input():
	if i == a[j]:
		j += 1
if j == 5:
	print('YES')
else:
	print('NO')


def rmc(s, c):
	x = -1
	while 0 - x <= len(s):
		if s[x] == c:
			return len(s) + x
		x -= 1

def lmc(s, c):
	return s.index(c)
s = str(input())
if s.count('h') > 0:
	p = lmc(s, 'h')
	s = s[p:]
	if s.count('e') > 0:
		q = lmc(s, 'e')
		s = s[q:]
		if s.count('i') > 1:
			a1 = lmc(s, 'i')
			a2 = rmc(s, 'i')
			if s[a1:a2 + 1].count('d') > 0:
				print('YES')
				exit()
print('NO')


s = input()
l = ['h', 'e', 'i', 'd', 'i']
i = 0
for j in s:
	if i < 5 and j == l[i]:
		i += 1
if i == 5:
	print('YES')
else:
	print('NO')


n = input()
cnt = 0
chk = 1
for i in range(len(n)):
	if n[i] == 'h' and chk == 1:
		cnt += 1
		chk += 1
	elif n[i] == 'e' and chk == 2:
		cnt += 1
		chk += 1
	elif n[i] == 'i' and chk == 3:
		cnt += 1
		chk += 1
	elif n[i] == 'd' and chk == 4:
		cnt += 1
		chk += 1
	elif n[i] == 'i' and chk == 5:
		cnt += 1
		chk += 1
if cnt == 5:
	print('YES')
else:
	print('NO')


n = input()
s = ''
v = 0
w = 0
x = 0
y = 0
z = 0
for i in range(len(n)):
	if n[i] == 'h':
		s = s + n[i]
		v = i
		break
for j in range(v + 1, len(n)):
	if n[j] == 'e':
		s = s + n[j]
		w = j
		break
for k in range(w + 1, len(n)):
	if n[k] == 'i':
		s = s + n[k]
		x = k
		break
for l in range(x + 1, len(n)):
	if n[l] == 'd':
		s = s + n[l]
		y = l
		break
for m in range(y + 1, len(n)):
	if n[m] == 'i':
		s = s + n[m]
		break
if s == 'heidi':
	print('YES')
else:
	print('NO')


arr = input()
count = 0
if len(arr) <= 1000:
	for i in arr:
		if count == 0 and i == 'h':
			count += 1
		elif count == 1 and i == 'e':
			count += 1
		elif count == 2 and i == 'i':
			count += 1
		elif count == 3 and i == 'd':
			count += 1
		elif count == 4 and i == 'i':
			count += 1
	if count == 5:
		print('YES')
	else:
		print('NO')


def subsequence(seq, subseq):
	seq = seq.lower()
	subseq = subseq.lower()
	for char in subseq:
		try:
			seq = seq[seq.index(char) + 1:]
		except:
			return False
	return True
s = input()
print('YES' if subsequence(s, 'heidi') else 'NO')


s = input()
h = s.find('h')
e = s.find('e', h)
i1 = s.find('i', e)
d = s.find('d', i1)
i2 = s.find('i', d)
if -1 < h < e < i1 < d < i2:
	print('YES')
else:
	print('NO')


s = input().strip()
l = len(s)
seq = 'heidi'
flag = True
i = 0
found = 0
for j in range(l):
	temp = s.find(seq[i], found)
	if temp == -1:
		flag = False
		break
	i += 1
	found = temp
	if i == 5:
		break
if flag and i == 5:
	print('YES')
else:
	print('NO')


s = input()
x = 'heidi'
k = 0
for ch in s:
	if ch == x[k]:
		k += 1
	if k == 5:
		print('YES')
		break
else:
	print('NO')


def is_subseq(x, y):
	it = iter(y)
	return all((c in it for c in x))
target_subsequence = 'heidi'
s = input()
if is_subseq(target_subsequence, s):
	print('YES')
else:
	print('NO')


z = ['h', 'e', 'i', 'd', 'i']
for i in input() + '.':
	try:
		if z[0] == i:
			z.pop(0)
	except:
		exit(print('YES'))
print('NO')


s = input()
to_find = 'heidi'
n = 0
for i in list(s):
	if i == to_find[n]:
		n += 1
	if n == 5:
		print('YES')
		break
else:
	print('NO')


n = str(input())
st = 'heidi'
cnt = 0
for i in n:
	if i == st[cnt]:
		cnt += 1
	if cnt == 5:
		break
print('YES' if cnt == 5 else 'NO')


t = input()
h = 'heidi'
p = ''
u = 0
for k in t:
	if k == h[u]:
		p += k
		u += 1
		if u == len(h):
			break
if p == h:
	print('YES')
else:
	print('NO')


s = input()
key = 'heidi'
counter = 0
is_found = []
for (index, letter) in enumerate(s):
	if len(is_found) == 5:
		break
	if s[index] == key[counter]:
		is_found.append(key[counter])
		counter = counter + 1
if key == ''.join(is_found):
	print('YES')
else:
	print('NO')


a = input()
if 'h' in a:
	b = a[a.index('h'):]
	if 'e' in b:
		d = b[b.index('e'):]
		if 'i' in d:
			e = d[d.index('i'):]
			if 'd' in e:
				f = e[e.index('d'):]
				if 'i' in f:
					print('YES')
				else:
					print('NO')
			else:
				print('NO')
		else:
			print('NO')
	else:
		print('NO')
else:
	print('NO')


s = input()
try:
	pos_h = s.index('h')
	pos_e = s.index('e', pos_h)
	pos_i = s.index('i', pos_e)
	pos_d = s.index('d', pos_i)
	pos_i_2 = s.index('i', pos_d)
	pos_i_2 = s.index('i', pos_i_2)
except:
	print('NO')
else:
	print('YES')


i = input()
x = 'heidi.'
m = 0
for n in i:
	if n == x[m]:
		m += 1
if m == 5:
	print('YES')
else:
	print('NO')


word = str(input())
wza = 0
if 'h' in word and 'i' in word:
	a = word.index('h')
	b = word[::-1]
	c = b.index('i')
	d = len(word) - c
	word = word[a:d]
else:
	wza = 1
if wza == 0:
	if 'e' in word:
		m = word.index('e')
		word = word[m:]
		if 'i' in word:
			k = word.index('i')
			word = word[k:]
			if 'd' in word:
				wza = 0
			else:
				wza = 1
		else:
			wza = 1
	else:
		wza = 1
if wza == 1:
	print('NO')
else:
	print('YES')


s = input()
a = 'heidi'
(j, flag) = (0, 0)
for i in range(len(s)):
	if s[i] == a[j]:
		j += 1
	if j == 5:
		flag = 1
		break
if flag:
	print('YES')
else:
	print('NO')


s = input()
st = ['h', 'e', 'i', 'd', 'i']
k = 0
z = 0
for i in range(len(s)):
	if s[i] == st[k]:
		k += 1
		if k == 5:
			z = 1
			break
	else:
		continue
if z == 0:
	print('NO')
else:
	print('YES')


def main():
	news = input()
	news_length = len(news)
	detector = 'heidi'
	index = -1
	try:
		for char in detector:
			index = next((i for i in range(index + 1, news_length) if news[i] == char))
		print('YES')
	except StopIteration:
		print('NO')
main()


s = input()
sample = 'heidi'
j = 0
for i in s:
	if sample[j] == i:
		j = j + 1
	if j == len(sample):
		break
if j == len(sample):
	print('YES')
else:
	print('NO')


s = input()

def f(s):
	for i in 'heidi':
		if i in s:
			s = s[s.index(i) + 1:]
		else:
			return 'NO'
	return 'YES'
print(f(s))


s = str(input())
target = 'heidi'
(i, j) = (0, 0)
while True:
	if s[i] == target[j]:
		i += 1
		j += 1
	else:
		i += 1
	if j == len(target):
		break
	elif i == len(s):
		break
	else:
		pass
print('YES') if j == len(target) else print('NO')


s = input()
m = 'heidi'
for c in m:
	a = s.find(c)
	if a == -1:
		print('NO')
		return
	s = s[a + 1:]
print('YES')


import sys
import math

def main():
	s = sys.stdin.readline().strip()
	count = 0
	p = 'heidi0'
	for q in s:
		if q == p[count]:
			count += 1
	print(['YES', 'NO'][count < 5])
main()


Input = lambda : map(int, input().split())
Heidi = 'heidi?'
T = 0
s = input()
for i in s:
	if i == Heidi[T]:
		T += 1
print('YES' if T == 5 else 'NO')


line = input()
heidi = 'heidi'
idx = 0
for ch in line:
	if ch == heidi[idx]:
		idx = idx + 1
		if idx >= len(heidi):
			break
if idx >= len(heidi):
	print('YES')
else:
	print('NO')


x = input()
h = 'heidi'
i = 0
l = len(h)
for a in x:
	if a == h[i]:
		i += 1
	if i == l:
		break
if i == l:
	print('YES')
else:
	print('NO')


s = input()

def findS(s, sub):
	if len(sub) == 0:
		return 0
	if len(s) == 0:
		return -1
	num = s.find(sub[0])
	if num == -1:
		return -1
	return findS(s[num + 1:], sub[1:])
if findS(s, 'heidi') != -1:
	print('YES')
else:
	print('NO')


import sys
import math
import bisect
import itertools
import random
import re

def is_subsequence(s, t):
	n = len(s)
	m = len(t)
	j = 0
	for i in range(n):
		if s[i] == t[j]:
			j += 1
			if j == m:
				return True
	return False

def main():
	if is_subsequence(input(), 'heidi'):
		print('YES')
	else:
		print('NO')
main()


def main_function():
	word = 'heidi'
	s = input()
	i = 0
	j = 0
	while j < len(s):
		if s[j] == word[i]:
			i += 1
			j += 1
		else:
			j += 1
		if i == len(word):
			return 'YES'
	return 'NO'
print(main_function())


s = input()
name = 'heidi'
len1 = len(s)
len2 = len(name)
counter = 0
for a in range(len2):
	index = s.find(name[a])
	if index == -1:
		print('NO')
		counter = 1
		break
	if index == len1 - 1 and a < len2 - 1:
		print('NO')
		counter = 1
		break
	s = s[index + 1:]
if counter == 0:
	print('YES')


s = input()
testCase = ['h', 'e', 'i', 'd', 'i']
x = 0
temp = [c for c in s if c in testCase]
i = 0
while i < len(temp):
	if x == 5:
		break
	if temp[i] == testCase[x]:
		x += 1
		i += 1
	elif temp[i] != testCase[x]:
		i += 1
if x != 5:
	print('NO')
else:
	print('YES')


a = str(input())
l = ['h', 'e', 'i', 'd', 'i']
s = ''
t = 'NO'
for i in range(5):
	if l[i] in a:
		s += l[i]
		a = a[1 + a.index(l[i]):]
		if s == 'heidi':
			t = 'YES'
print(t)


def solve(s):
	target = 'heidi'
	j = 0
	t_len = len(target)
	s_len = len(s)
	for i in range(0, s_len):
		if s[i] == target[j]:
			j += 1
			if j == t_len:
				break
	return 'YES' if j == t_len else 'NO'
s = input()
print(solve(s))


string = input()
s = 'heidiN'
var = 0
for c in string:
	if s[var] == c:
		var += 1
if var == 5:
	print('YES')
else:
	print('NO')


news = input()
lf = 'heidi'
count = 0
for i in 'heidi':
	index = news.find(i)
	news = news[index:]
	if index != -1:
		count += 1
if count == 5:
	print('YES')
else:
	print('NO')


s = input()
flag = False
ind = [0, 0, 0, 0, 0]
for i in range(len(s)):
	if s[i] == 'h':
		ind[0] = i + 1
		break
if ind[0]:
	for i in range(ind[0] - 1, len(s)):
		if s[i] == 'e':
			ind[1] = i + 1
			break
if ind[1]:
	for i in range(ind[1] - 1, len(s)):
		if s[i] == 'i':
			ind[2] = i + 1
			break
if ind[2]:
	for i in range(ind[2] - 1, len(s)):
		if s[i] == 'd':
			ind[3] = i + 1
			break
if ind[3]:
	for i in range(ind[3] - 1, len(s)):
		if s[i] == 'i':
			ind[4] = i + 1
			flag = True
			break
print('YES' if flag else 'NO')


s = input()
h1 = 0
e1 = 0
i1 = 0
d1 = 0
i2 = 0
for a in range(0, len(s)):
	if s[a] == 'h':
		h1 = 1
	if s[a] == 'e' and h1 == 1:
		e1 = 1
	if s[a] == 'i' and (h1 and e1) == 1:
		i1 = 1
	if s[a] == 'd' and (h1 and e1 and i1) == 1:
		d1 = 1
	if s[a] == 'i' and (h1 and e1 and i1 and d1) == 1:
		i2 = 1
if i2 == 1:
	print('YES')
else:
	print('NO')


s = input()
n = len(s)
r = 'heidi'
temp = ''
(i, j) = (0, 0)
while i < n:
	while i < n and j < 5 and (s[i] != r[j]):
		i += 1
	if i < n and j < 5 and (s[i] == r[j]):
		temp += r[j]
	j += 1
	i += 1
if temp == r:
	print('YES')
else:
	print('NO')


import math
import sys
import re

def func(n):
	if 'h' not in n:
		return 'NO'
	else:
		a = n.index('h')
		if 'e' not in n[a:]:
			return 'NO'
		else:
			b = n[a:].index('e')
			if 'i' not in n[a:][b:]:
				return 'NO'
			else:
				c = n[a:][b:].index('i')
				l1 = n[a:][b:][c:]
				if 'd' not in l1:
					return 'NO'
				else:
					d = l1.index('d')
					l2 = l1[d:]
					if 'i' not in l2:
						return 'NO'
					else:
						return 'YES'
n = input()
print(func(n))


def f():
	print('NO')
	exit()
s = input()
l = len(s)
for i in range(l - 4):
	if s[i] == 'h':
		for j in range(i, l - 3):
			if s[j] == 'e':
				for i in range(j, l - 2):
					if s[i] == 'i':
						for j in range(i, l - 1):
							if s[j] == 'd':
								for i in range(j, l):
									if s[i] == 'i':
										print('YES')
										exit()
								else:
									f()
						else:
							f()
				else:
					f()
		else:
			f()
else:
	f()


t = input()
p = 'heidi'
j = 0
for c in t:
	if c == p[j]:
		j += 1
	if j == 5:
		print('YES')
		break
else:
	print('NO')


s = input()
try:
	i1 = s.index('h')
	i2 = s.index('e', i1)
	i3 = s.index('i', i2)
	i4 = s.index('d', i3)
	s.index('i', i4)
	print('YES')
except ValueError:
	print('NO')


s = input()
answer = 'YES'
for char in 'heidi':
	if char in s:
		s = s[s.index(char) + 1:]
	else:
		answer = 'NO'
		break
print(answer)


n = str(input())
word = 'heidi'
kek = 0
for i in n:
	if i == word[kek]:
		kek += 1
	if kek == 5:
		break
if kek == 5:
	print('YES')
else:
	print('NO')


str = input()
h = False
e = False
i = False
d = False
i_2 = False
for a in str:
	if a == 'h' and h == False:
		h = True
	if a == 'e' and h:
		e = True
	if a == 'i' and h and e:
		i = True
	if a == 'd' and h and e and i:
		d = True
	if a == 'i' and h and e and i and d:
		i_2 = True
if h and e and i and d and i_2:
	print('YES')
else:
	print('NO')


s = input()
a = 'heidi'
u = s
q = 0
for i in range(5):
	u = u[q:]
	w = u.find(a[i])
	if w == -1:
		print('NO')
		break
	q = w + 1
else:
	print('YES')


l = list(input())
target = list('heidi')
j = 0
for i in range(len(l)):
	if l[i] == target[j]:
		j += 1
	if j == 5:
		print('YES')
		exit()
print('NO')


test = 'heidi'
s = input()
count = 0
isFake = False
for i in range(len(s)):
	if s[i] == test[count]:
		count = count + 1
	if count >= len(test):
		isFake = True
		break
if isFake:
	print('YES')
else:
	print('NO')


a = str(input(''))
length = len(a)
if a.find('h') != -1:
	a = a[a.find('h') + 1:]
	if a.find('e') != -1:
		a = a[a.find('e') + 1:]
		if a.find('i') != -1:
			a = a[a.find('i') + 1:]
			if a.find('d') != -1:
				a = a[a.find('d') + 1:]
				if a.find('i') != -1:
					print('YES')
					exit()
				else:
					print('NO')
					exit()
			else:
				print('NO')
				exit()
		else:
			print('NO')
			exit()
	else:
		print('NO')
		exit()
else:
	print('NO')
	exit()


s = list(input())
un = ['h', 'e', 'i', 'd', 'i']
sc = 0
for i in s:
	if sc == 5:
		break
	if i == un[sc]:
		sc += 1
if sc == 5:
	print('YES')
else:
	print('NO')


m = 'heidi'
n = input()
a = 0
for i in range(len(n)):
	if m[a] == n[i]:
		a += 1
		if a == 5:
			print('YES')
			exit()
print('NO')


a = input()
b = 'heidi'
t = 0
f = 0
for i in a:
	if i == b[t]:
		t += 1
	if t > 4:
		print('YES')
		f = 1
		break
if t <= 4 and f == 0:
	print('NO')


a = input()
if len(a) <= 5:
	print('NO')
else:
	t = 0
	b = 'heidi'
	for i in a:
		if i == b[t]:
			t += 1
			if t == 5:
				print('YES')
				break
	else:
		if t == 5:
			print('YES')
		else:
			print('NO')


s = input()
a = 'heidi'
j = 0
for i in range(len(s)):
	if s[i] == a[j]:
		j += 1
	if j == 5:
		print('YES')
		exit()
print('NO')


y = input()
if y == 'heidi':
	print('NO')
else:
	it = iter(y)
	if all((c in it for c in 'heidi')):
		print('YES')
	else:
		print('NO')


s = input()
(a, b, c) = ('heidi', '', 0)
for i in s:
	if c < 5 and i == a[c]:
		b += i
		c += 1
print('YES' if a == b else 'NO')


s = input()
i = 0
string = 'heidi'
while i < len(s):
	k = s.find(string[0], i)
	if k != -1:
		string = string[1:]
		i = k
		if len(string) == 0:
			print('YES')
			break
	else:
		print('NO')
		break
else:
	print('NO')


def contains(s1, s2):
	i2 = 0
	for c in s1:
		if c == s2[i2]:
			i2 += 1
			if i2 == len(s2):
				return True
	return False
s = input()
if contains(s, 'heidi'):
	print('YES')
else:
	print('NO')


a = input()
ls = ['h', 'e', 'i', 'd', 'i']
for i in ls:
	if i in a:
		a = a.replace(a[0:a.index(i) + 1], '', 1)
	else:
		print('NO')
		break
else:
	print('YES')


s = input()
sa = 'heidi'
j = 0
nk = 0
for i in s:
	if sa[j] == i:
		j += 1
	if j == 5:
		nk = 1
		print('YES')
		break
if nk == 0:
	print('NO')


s = input()
a = s.find('h')
b = s.find('e', a + 1)
c = s.find('i', b + 1)
d = s.find('d', c + 1)
e = s.find('i', d + 1)
if min(a, b, c, d, e) != -1:
	print('YES')
else:
	print('NO')


import sys
Input = sys.stdin.readline
s = Input()
a = 'heidi'
q = 0
for i in s:
	if i == a[q]:
		q += 1
	if q == 5:
		break
print('YES' if q == 5 else 'NO')


import sys
s = input()
counter = 0
f = 'heidi'
for i in range(len(s)):
	if s[i] == f[counter]:
		counter += 1
	if counter > 4:
		print('YES')
		return
print('NO')


def isSubSequence(str1, str2):
	(m, n, i, j) = (len(str1), len(str2), 0, 0)
	while j < m and i < n:
		if str1[j] == str2[i]:
			j = j + 1
		i = i + 1
	return j == m
str1 = 'heidi'
str2 = input()
if isSubSequence(str1, str2):
	print('YES')
else:
	print('NO')


a = list(input())
b = list('heidi')
while a and b:
	if a[-1] == b[-1]:
		b.pop()
	a.pop()
print('NO' if b else 'YES')


s = input()
m = 'heidi'
for c in m:
	a = s.find(c)
	if a == -1:
		print('NO')
		exit(0)
	s = s[a + 1:]
print('YES')


x = input()
x = list(x)
heidi = ['h', 'e', 'i', 'd', 'i']
for letter in x:
	if letter == heidi[0]:
		heidi.pop(0)
	if len(heidi) == 0:
		print('YES')
		exit()
print('NO')


s = input()
i = -1
for ch in 'heidi':
	i = s.find(ch, i + 1)
	if i < 0:
		print('NO')
		break
else:
	print('YES')


s1 = 'heidi'
s = input()
x = 0
for i in s:
	if x == 5:
		break
	if i == s1[x]:
		x += 1
print(['NO', 'YES'][x == 5])


ns = 'heidi'
s = input()
index = 0
for char in s:
	if char == ns[index]:
		index += 1
	if index == 5:
		print('YES')
		break
else:
	print('NO')


s = input()
t = 'heidi'
j = 0
res = ''
for i in s:
	if i == t[j]:
		res += i
		j += 1
		if res == t:
			print('YES')
			break
if res != t:
	print('NO')


str_in = input()
contains_heidi = False
found_h = False
found_e = False
found_i = False
found_d = False
for char in str_in:
	if found_h or char == 'h':
		found_h = True
		if found_e or char == 'e':
			found_e = True
			if found_i or char == 'i':
				found_i = True
				if found_d or char == 'd':
					found_d = True
					if char == 'i':
						contains_heidi = True
if contains_heidi:
	print('YES')
else:
	print('NO')


n = input()
a = 0
for i in n:
	if i == 'h' and a == 0:
		a += 1
	elif i == 'e' and a == 1:
		a += 1
	elif i == 'i' and a == 2:
		a += 1
	elif i == 'd' and a == 3:
		a += 1
	elif i == 'i' and a == 4:
		a += 1
if a == 5:
	print('YES')
else:
	print('NO')


match_sequence = 'heidi'
match_sequence_length = len(match_sequence)
test_case = input()
current_match_index = 0
for letter in test_case:
	if letter == match_sequence[current_match_index] and current_match_index < 5:
		current_match_index += 1
		if current_match_index == 5:
			break
if current_match_index == match_sequence_length and len(test_case) > 5:
	print('YES')
else:
	print('NO')


s = input()
try:
	h = s.index('h')
	e = s.index('e', h)
	i = s.index('i', e)
	d = s.index('d', i)
	ii = s.index('i', d)
except:
	print('NO')
else:
	print('YES')


s = input()
s1 = 0
s2 = 0
s3 = 0
s4 = 0
s5 = 0
l = []
for h in s:
	l.append(h)
for i in range(len(l)):
	if l[i] == 'h':
		s1 += 1
		del l[0:i]
		break
for i in range(len(l)):
	if l[i] == 'e':
		s2 += 1
		del l[0:i]
		break
for i in range(len(l)):
	if l[i] == 'i':
		s3 += 1
		del l[0:i]
		break
for i in range(len(l)):
	if l[i] == 'd':
		s4 += 1
		del l[0:i]
		break
for i in range(len(l)):
	if l[i] == 'i':
		s5 += 1
		del l[0:i]
		break
if s1 == 1 and s2 == 1 and (s3 == 1) and (s4 == 1) and (s5 == 1):
	print('YES')
else:
	print('NO')


from sys import stdin
max_val = int(10000000000000.0)
min_val = int(-10000000000000.0)

def read_int():
	return int(stdin.readline())

def read_ints():
	return [int(x) for x in stdin.readline().split()]

def read_str():
	return input()

def read_strs():
	return [x for x in stdin.readline().split()]
ins = input()
pos = 0
need = 'heidi'
for i in ins:
	if i == need[pos]:
		pos += 1
		if pos == 5:
			break
print(['NO', 'YES'][pos == 5])


a = ['h', 'e', 'i', 'd', 'i']
n = list(input())
n.reverse()
for i in range(len(n)):
	if len(a) == 0:
		print('YES')
		exit()
	if a[-1] == n[i]:
		del a[-1]
print('NO')


string = input()
heidi = 'heidi'
currpos = 0
flag = 0
for letter in string:
	if letter == heidi[currpos]:
		currpos += 1
	if currpos == len(heidi):
		flag = 1
		break
if flag:
	print('YES')
else:
	print('NO')


s = input()
l = 'heidi'
i = 1
j = 0
if len(s) <= 5:
	print('NO')
	exit()
while i <= len(s) - 1:
	if l[j] == s[i]:
		j += 1
	i += 1
	if j == 5:
		print('YES')
		exit()
print('NO')


s = 'heidi$'
i = 0
for x in input():
	if x == s[i]:
		i += 1
print('YNEOS'[i < 5::2])


s = input()
(h, e, iFirst, d, iSecond) = (False, False, False, False, False)
for x in s:
	if x == 'h' and (not h):
		h = True
	if x == 'e' and h and (not e):
		e = True
	if x == 'i' and e and (not iFirst):
		iFirst = True
	if x == 'd' and iFirst:
		d = True
	if x == 'i' and d:
		iSecond = True
if h and e and d and iFirst and iSecond:
	print('YES')
else:
	print('NO')


s = input()
check = 'heidi'
counter = 0
for ch in s:
	if counter >= 5:
		break
	if ch == check[counter]:
		counter += 1
print(['NO', 'YES'][counter == 5])


news_str = input()
h = 'heidi'
i = 0
isFake = False
for c in news_str:
	if h[i] == c:
		i = i + 1
	if i >= len(h):
		isFake = True
		break
if isFake:
	print('YES')
else:
	print('NO')


t = input().strip()
h = 'heidi'
i = 0
for s in t:
	if h[i] == s:
		i += 1
	if i == 5:
		break
if i == 5:
	print('YES')
else:
	print('NO')


n = list(input())
c = 0
for i in range(len(n)):
	if c == 0 and n[i] == 'h':
		c += 1
	elif c == 1 and n[i] == 'e':
		c += 1
	elif c == 2 and n[i] == 'i':
		c += 1
	elif c == 3 and n[i] == 'd':
		c += 1
	elif c == 4 and n[i] == 'i':
		c += 1
		break
if c == 5:
	print('YES')
else:
	print('NO')


def contains(s, frm, p, pos):
	if pos == len(p):
		return True
	ind = s.find(p[pos], frm)
	if ind < 0:
		return False
	else:
		return contains(s, ind + 1, p, pos + 1)
print(('NO', 'YES')[contains(input(), 0, 'heidi', 0)])


s = input()
j = 0
sh = 'heidi'
for i in s:
	if i == sh[j]:
		j += 1
		if j == 5:
			print('YES')
			exit(0)
else:
	print('NO')


import sys
import re

def main():
	s = re.sub('[^heid]', '', sys.stdin.read().strip())
	return ('NO', 'YES')[bool(re.search('.*'.join('heidi'), re.sub('(.)\\1+', '\\1', s)))]
print(main())


def ss(a, b):
	m = len(a)
	n = len(b)
	i = 0
	j = 0
	while i < m and j < n:
		if a[i] == b[j]:
			i += 1
		j += 1
	return i == m
a = 'heidi'
b = input()
print('YES' if ss(a, b) else 'NO')


compare = 'heidi'
t = 0
n = input()
for i in n:
	if i == compare[t]:
		t = t + 1
		if t == 5:
			print('YES')
			break
if t < 5:
	print('NO')


s = input()
i = 0
s1 = 'heidi'
s2 = ''
for j in s:
	if s1[i] == j:
		s2 += j
		i += 1
		if i == 5:
			break
if s2 == 'heidi':
	print('YES')
else:
	print('NO')


substr = 'heidi'
sub_idx = 0
str_idx = 0
s = input()
for i in range(len(s)):
	if s[i] == substr[sub_idx]:
		sub_idx += 1
	if sub_idx == len(substr):
		print('YES')
		exit(0)
print('NO')


s = input()
string = ''
for i in range(len(s)):
	if string == '' and s[i] == 'h':
		string += 'h'
	if string == 'h' and s[i] == 'e':
		string += 'e'
	if string == 'he' and s[i] == 'i':
		string += 'i'
	if string == 'hei' and s[i] == 'd':
		string += 'd'
	if string == 'heid' and s[i] == 'i':
		string += 'i'
		break
if string == 'heidi':
	print('YES')
else:
	print('NO')


s = str(input())
h = 'heidi'
cor = True
for i in h:
	if i in s:
		s = s[s.index(i):]
	else:
		cor = False
if cor:
	print('YES')
else:
	print('NO')


s = input()
s1 = 0
l = []
for h in s:
	l.append(h)
for i in range(len(l)):
	if l[i] == 'h':
		s1 += 1
		del l[0:i]
		break
for i in range(len(l)):
	if l[i] == 'e':
		s1 += 1
		del l[0:i]
		break
for i in range(len(l)):
	if l[i] == 'i':
		s1 += 1
		del l[0:i]
		break
for i in range(len(l)):
	if l[i] == 'd':
		s1 += 1
		del l[0:i]
		break
for i in range(len(l)):
	if l[i] == 'i':
		s1 += 1
		del l[0:i]
		break
if s1 == 5:
	print('YES')
else:
	print('NO')


cur = 0
st = 'heidi'
l = [0] * 5
for i in input():
	if i == st[cur]:
		l[cur] = 1
		cur += 1
	if l[4] == 1:
		break
if l[4] == 1:
	print('YES')
else:
	print('NO')


x = input()
a = 'heidi'
b = 0
for i in x:
	if i == a[b]:
		b = b + 1
		if b == 5:
			break
if b == 5:
	print('YES')
else:
	print('NO')


s = input()
test = 'heidi'
k = 0
for i in range(len(s)):
	if s[i] == test[k]:
		k += 1
		if k == 5:
			print('YES')
			break
if k != 5:
	print('NO')


string = input()

def search(string, input='heidi'):
	start = 0
	for c in string:
		if c == input[start]:
			start += 1
		if start == len(input):
			return True
	return False
if search(string):
	print('YES')
else:
	print('NO')


a = input()
s = 'heidi'
c = 0
for x in a:
	if c == 5:
		break
	if x == s[c]:
		c += 1
print('YES') if c == 5 else print('NO')


n = input()
nlist = list(n)
lookfor = 'heidi'
count = 0
for x in 'heidi':
	index = n.find(x)
	n = n[index:]
	if index != -1:
		count += 1
if count == 5:
	print('YES')
else:
	print('NO')


a = list(input())
b = ['h', 'e', 'i', 'd', 'i']
c = []
s = 'YES'
n = 0
for x in range(len(b)):
	for y in range(n, len(a)):
		if b[x] == a[y]:
			c.append(y)
			a[y] = ' '
			n = y
			break
if len(c) == 5:
	for x in range(len(c) - 1):
		if c[x] > c[x + 1]:
			s = 'NO'
			break
else:
	s = 'NO'
print(s)


s = input()
(bul, bul2, bul3, bul4) = (False, False, False, False)
for x in range(len(s)):
	if bul or s[x] == 'h':
		bul = True
		if bul2 or s[x] == 'e':
			bul2 = True
			if bul3 or s[x] == 'i':
				bul3 = True
				if bul4 or s[x] == 'd':
					bul4 = True
					if s[x] == 'i':
						print('YES')
						break
else:
	print('NO')


s = input()
a = 'heidi'

def check(x, y):
	m = len(x)
	n = len(y)
	(i, j) = (0, 0)
	while i < m and j < n:
		if x[i] == y[j]:
			i += 1
		j += 1
	return i == m
if check(a, s):
	print('YES')
else:
	print('NO')


def main():
	s = input()
	state = 0
	for i in range(len(s)):
		if s[i] == 'h':
			s = s[i:]
			state += 1
			break
	if state == 1:
		for i in range(len(s)):
			if s[i] == 'e':
				s = s[i:]
				state += 1
				break
	if state == 2:
		for i in range(len(s)):
			if s[i] == 'i':
				s = s[i:]
				state += 1
				break
	if state == 3:
		for i in range(len(s)):
			if s[i] == 'd':
				s = s[i:]
				state += 1
				break
	if state == 4:
		for i in range(len(s)):
			if s[i] == 'i':
				s = s[i:]
				state += 1
				break
	return 'YES' if state == 5 else 'NO'
print(main())


s = input()
p = 'heidi'
idx = 0
for c in s:
	if c == p[idx]:
		idx += 1
		if idx >= len(p):
			break
ans = ['NO', 'YES'][idx == len(p)]
print(ans)


TN = 1

def solution():
	s = input()
	lst = ['h', 'e', 'i', 'd', 'i']
	cur = 0
	for i in s:
		if i == lst[cur]:
			cur += 1
		if cur == 5:
			print('YES')
			break
	else:
		print('NO')
while TN != 0:
	solution()
	TN -= 1


x = input()
s = 0
ans = ''
lookup = ['h', 'e', 'i', 'd', 'i']
for item in lookup:
	x = x[s:]
	if x.count(item) != 0:
		ans = ans + item
		s = x.index(item)
print({True: 'YES', False: 'NO'}[ans == 'heidi'])


string = input()
heidi = 'heidi'
temp = 0
found = False
for i in range(0, len(string)):
	if heidi[temp] == string[i]:
		temp = temp + 1
		if temp > 4:
			found = True
			break
if found:
	print('YES')
else:
	print('NO')


s = 'heidi'
k = 0
a = input()
for i in range(len(a)):
	if a[i] == s[k]:
		k += 1
	if k >= len(s):
		break
if k >= len(s):
	print('YES')
else:
	print('NO')


s = input()
pr = 'heidi'
if 'h' in s and 'i' in s:
	ind1 = s.index('h')
	ind2 = s[::-1].index('i')
	br = 1
	for i in range(ind1, len(s) - ind2):
		if s[i] == pr[br]:
			br += 1
		if br == 5:
			print('YES')
			break
	if br < 5:
		print('NO')
else:
	print('NO')


s = list(input())
h = 0
if 'h' not in s or 'e' not in s or 'i' not in s or ('d' not in s):
	print('NO')
else:
	p = []
	for i in s:
		if i == 'h' or i == 'e' or i == 'i' or (i == 'd'):
			p.append(i)
	for i in range(0, len(p)):
		if p[i] == 'h':
			h += 1
			break
	for j in range(i, len(p)):
		if p[j] == 'e':
			h += 1
			break
	for i in range(j, len(p)):
		if p[i] == 'i':
			h += 1
			break
	for j in range(i, len(p)):
		if p[j] == 'd':
			h += 1
			break
	for i in range(j, len(p)):
		if p[i] == 'i':
			h += 1
			break
	if h != 5:
		print('NO')
	else:
		print('YES')


x = input()
xl = len(x)
h = False
e = False
l = False
l2 = False
o = False
tis = 'NO'
for i in range(xl):
	if x[i] == 'h' and h == False:
		h = True
		for f in range(i):
			x.replace(x[f], '')
	if x[i] == 'e' and e == False and (h == True):
		e = True
		for f in range(i):
			x.replace(x[f], '')
	if x[i] == 'i' and l == False and (e == True):
		l = True
		for f in range(i):
			x.replace(x[f], '')
		f = False
	if x[i] == 'd' and l2 == False and (l == True) and f:
		l2 = True
		for f in range(i):
			x.replace(x[f], '')
	if x[i] == 'i' and o == False and (l2 == True):
		o = True
		for f in range(i):
			x.replace(x[f], '')
	f = True
if h and e and l and l2 and o:
	tis = 'YES'
print(tis)


def fake_news(s, target='heidi'):
	index = 0
	for c in s:
		if c == target[index]:
			index += 1
			if index == len(target):
				return 'YES'
	return 'NO'
print(fake_news(input()))


lst1 = list(input())

def prio(char):
	if char == '0':
		return 0
	if char == 'h':
		return 1
	if char == 'e':
		return 2
	if char == 'i':
		return 3
	if char == 'd':
		return 4
	else:
		return 100

def top(lst2):
	return lst2[len(lst2) - 1]
lst2 = ['0']
m = 0
k = 0
for i in range(len(lst1)):
	if prio(lst1[i]) - prio(top(lst2)) == 1:
		lst2.append(lst1[i])
	if len(lst2) == 5:
		m = 1
		break
for j in range(i, len(lst1)):
	if lst1[j] == 'i':
		k = 1
		break
if k == 1 and m == 1:
	print('YES')
else:
	print('NO')


a = iter(input())
b = 'heidi'
print('YES' * all((i in a for i in b)) or 'NO')


def isSubsequence(string, sub):
	letters = list(sub)
	for part in string:
		try:
			if part == letters[0]:
				letters.pop(0)
		except IndexError:
			return True
	return len(letters) == 0
news = input()
if isSubsequence(news, 'heidi'):
	print('YES')
else:
	print('NO')


s = input()
new = 'heidi'
found = 0
for i in range(len(s)):
	if s[i] == new[found]:
		found += 1
		if found == len(new):
			print('YES')
			exit(0)
	else:
		continue
print('NO')


string = input()
hiedi = ['h', 'e', 'i', 'd', 'i']
count = 0
while len(hiedi) != 0 and count < len(string):
	if string[count] == hiedi[0]:
		hiedi.remove(hiedi[0])
	count += 1
if len(hiedi) == 0:
	print('YES')
else:
	print('NO')


import sys

def main():
	article = str(input())
	flag = heidifound(article)
	if flag != 5:
		print('NO')
	else:
		print('YES')

def heidifound(article):
	flag = 0
	for i in range(len(article)):
		if article[i] == 'h':
			flag = 1
			for j in range(i + 1, len(article)):
				if article[j] == 'e':
					flag = 2
					for x in range(j + 1, len(article)):
						if article[x] == 'i':
							flag = 3
							for d in range(x + 1, len(article)):
								if article[d] == 'd':
									flag = 4
									for c in range(d + 1, len(article)):
										if article[c] == 'i':
											flag = 5
											return flag
											break
							if flag != 3:
								break
					if flag != 2:
						break
			if flag != 1:
				break
	return flag
main()


s = input()
p = 'heidi'
j = 0
lst = []
for i in range(len(p)):
	while j < len(s):
		if p[i] == s[j]:
			lst.append(s[j])
			j = j + 1
			break
		else:
			j = j + 1
ls = ''.join(lst)
if ls == p:
	print('YES')
else:
	print('NO')


s = input()
t = 'heidi'
ps = 0
for e in s:
	if e == t[ps]:
		ps += 1
		if ps == len(t):
			print('YES')
			quit()
print('NO')


x = input()
flag = 1
for char in x:
	if char == 'h' and flag == 1:
		flag += 1
	elif char == 'e' and flag == 2:
		flag += 1
	elif char == 'i' and flag == 3:
		flag += 1
	elif char == 'd' and flag == 4:
		flag += 1
	elif char == 'i' and flag == 5:
		flag += 1
if flag == 6 and len(x) >= 6:
	print('YES')
else:
	print('NO')


s = input()
h = list('heidi')
ans = 'NO'
for i in s:
	if i == h[0]:
		h.pop(0)
		if not h:
			ans = 'YES'
			break
print(ans)


import sys
import math
get_string = lambda : sys.stdin.readline().strip()
get_int_list = lambda : list(map(int, sys.stdin.readline().strip().split()))
get_int = lambda : int(sys.stdin.readline())
s = get_string()
match = 'heidi'
pointer = 0
flag = False
for i in s:
	if i == match[pointer]:
		pointer += 1
		if pointer == 5:
			flag = True
			break
if flag:
	print('YES')
else:
	print('NO')


str = input()
check = ''
if str == 'heidi':
	print('NO')
else:
	for c in str:
		if c == 'h' and len(check) == 0:
			check += 'h'
		if c == 'e' and len(check) == 1:
			check += 'e'
		if c == 'i' and len(check) == 2:
			check += 'i'
		if c == 'd' and len(check) == 3:
			check += 'd'
		if c == 'i' and len(check) == 4:
			check += 'i'
		if len(check) == 5:
			break
if len(check) == 5:
	print('YES')
else:
	print('NO')


def lcs(a, b):
	lena = len(a)
	lenb = len(b)
	c = [[0 for i in range(lenb + 1)] for j in range(lena + 1)]
	for i in range(lena):
		for j in range(lenb):
			if a[i] == b[j]:
				c[i + 1][j + 1] = c[i][j] + 1
			elif c[i + 1][j] > c[i][j + 1]:
				c[i + 1][j + 1] = c[i + 1][j]
			else:
				c[i + 1][j + 1] = c[i][j + 1]
	return c
a = input()
b = 'heidi'
s1 = lcs(a, b)
if s1[-1][5] == 5:
	print('YES')
else:
	print('NO')


import sys
s = input()
start = 0
for c in 'heidi':
	x = s.find(c, start)
	if x > -1:
		start = x + 1
	else:
		print('NO')
		sys.exit()
print('YES')


s = input()
target = 'heidi'
k = 0
for i in s:
	if i == target[k]:
		if k == 4:
			k += 1
			break
		else:
			k += 1
if k == 5:
	print('YES')
else:
	print('NO')


substring = 'heidi'
input_string = input()

def subsequence(s, t):
	for i in range(len(s)):
		try:
			idx = t.index(s[i])
		except:
			return 'NO'
		t = t[idx + 1:]
	return 'YES'
res = subsequence(substring, input_string)
print(res)


mis = 'heidi'
x = input()
pos = 0
for i in x:
	if i == mis[pos]:
		pos += 1
		if pos == 5:
			break
if pos == 5:
	print('YES')
else:
	print('NO')


paper = input()
fake = 'heidi'
lst = []
for i in fake:
	lst.append(i)
i = 0
j = 0
while i < len(paper) and j < len(lst):
	if paper[i] == lst[j]:
		lst.pop(j)
	i += 1
if len(lst) != 0:
	print('NO')
else:
	print('YES')


_ = 'heidi'
n = input()
DFX = 0
for i in range(len(n)):
	if n[i] == 'heidi'[DFX]:
		DFX += 1
		if DFX == 5:
			print('YES')
			exit(0)
print('NO')


ch = input()
ch1 = ['h', 'e', 'i', 'd', 'i']
i = 0
j = 0
while i < len(ch) and j < 5:
	if ch[i] == ch1[j]:
		j += 1
	i += 1
if j == 5:
	print('YES')
else:
	print('NO')


s = input()
s2 = ['h', 'e', 'i', 'd', 'i']
n = [-1 for i in range(5)]
id = 0
for i in range(len(s)):
	if id < 5 and s[i] == s2[id] and (n[id] == -1):
		n[id] = i
		id += 1
for i in n:
	if i == -1:
		print('NO')
		break
else:
	print('YES')


l = list(input())
d = 0
x = []
z = []
for i in range(d, len(l)):
	if l[i] == 'h':
		x.append(i)
		z.append(l[i])
		d = x[-1]
		break
for i in range(d + 1, len(l)):
	if l[i] == 'e':
		x.append(i)
		z.append(l[i])
		d = x[-1]
		break
for i in range(d + 1, len(l)):
	if l[i] == 'i':
		x.append(i)
		z.append(l[i])
		d = x[-1]
		break
for i in range(d + 1, len(l)):
	if l[i] == 'd':
		x.append(i)
		z.append(l[i])
		d = x[-1]
		break
for i in range(d + 1, len(l)):
	if l[i] == 'i':
		x.append(i)
		z.append(l[i])
		d = x[-1]
		break
y = ''.join(z)
if y == 'heidi':
	print('YES')
else:
	print('NO')


def is_subsequence(x, y):
	x = list(x)
	for letter in y:
		if x and x[0] == letter:
			x.pop(0)
	return not x
s = input()
print('YES' if is_subsequence('heidi', s) else 'NO')


s = input()
a = 'heidi.'
j = 0
for i in s:
	if i == a[j]:
		j += 1
print('YNEOS'[j != 5::2])


import sys
import math
import itertools
import functools
import collections
import operator

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def revn(n):
	return str(n)[::-1]

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=2):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def convn(number, base):
	newnumber = 0
	while number > 0:
		newnumber += number % base
		number //= base
	return newnumber

def cdiv(n, k):
	return n // k + (n % k != 0)
s = 'heidi'
pos = 0
t = input()
for c in t:
	if c == s[pos]:
		pos += 1
	if pos == 5:
		exit(print('YES'))
print('NO')


string = input()
now = 0
for i in range(len(string)):
	if now == 0 and string[i] == 'h':
		now += 1
	if now == 1 and string[i] == 'e':
		now += 1
	if now == 2 and string[i] == 'i':
		now += 1
	if now == 3 and string[i] == 'd':
		now += 1
	if now == 4 and string[i] == 'i':
		now += 1
if now == 5:
	print('YES')
else:
	print('NO')


string = input()
h = False
e = False
i_1 = False
d = False
i_2 = False
for symbol in string:
	if h:
		if e:
			if i_1:
				if d:
					if i_2 is False:
						if symbol == 'i':
							i_2 = True
				elif symbol == 'd':
					d = True
			elif symbol == 'i':
				i_1 = True
		elif symbol == 'e':
			e = True
	elif symbol == 'h':
		h = True
if i_2:
	print('YES')
else:
	print('NO')


st = input()
name = 'heidi'
l = len(st)
i = 0
j = 0
flag = False
while i < l:
	if st[i] == name[j]:
		j += 1
		if j > 4:
			break
	i += 1
if j != 5:
	print('NO')
else:
	print('YES')


s = input()
fake = 'heidi'
count = 0
n = 0
for i in fake:
	for j in range(n, len(s)):
		if i == s[j]:
			count = count + 1
			n = j
			break
if count == 5:
	print('YES')
else:
	print('NO')


s = input()
t = 'heidi'
cnt = 0
for i in s:
	if cnt != 5 and i == t[cnt]:
		cnt += 1
if cnt < 5:
	print('NO')
else:
	print('YES')


s = list(input())
stack = list('heidi')
while s and stack:
	x = s.pop()
	if x == stack[-1]:
		stack.pop()
if not stack:
	print('YES')
else:
	print('NO')


heidi = 'heidi'
z = input()

def fakenews(heidi, z):
	a = len(heidi)
	b = len(z)
	c = 0
	d = 0
	while c < a and d < b:
		if heidi[c] == z[d]:
			c = c + 1
		d = d + 1
	return c == a
if fakenews(heidi, z):
	print('YES')
else:
	print('NO')


strings = input()
s = []
for c in strings:
	if c == 'h' and len(s) == 0:
		s += 'h'
	if c == 'e' and len(s) == 1:
		s += 'e'
	if c == 'i' and len(s) == 2:
		s += 'i'
	if c == 'd' and len(s) == 3:
		s += 'd'
	if c == 'i' and len(s) == 4:
		s += 'd'
		break
if len(s) == 5:
	print('YES')
else:
	print('NO')


s = str(input())
t = 0
n = 0
while t != 1 and n < len(s):
	if s[n] == 'h':
		t += 1
	n += 1
while t != 2 and n < len(s):
	if s[n] == 'e':
		t += 1
	n += 1
while t != 3 and n < len(s):
	if s[n] == 'i':
		t += 1
	n += 1
while t != 4 and n < len(s):
	if s[n] == 'd':
		t += 1
	n += 1
while t != 5 and n < len(s):
	if s[n] == 'i':
		t += 1
	n += 1
if t == 5:
	print('YES')
else:
	print('NO')


st = input()
ls = []
s = 'heidi'
p = 0
for i in s:
	q = st.find(i)
	if q == -1:
		break
	else:
		p += q
		ls.append(p)
		st = st[q:]
ps = ls
ps.sort()
print('YES') if ps == ls and len(ls) == len(s) else print('NO')


s = input()
f = 0
for i in range(len(s)):
	if s[i] == 'h' and f == 0:
		f = 1
	if s[i] == 'e' and f == 1:
		f = 2
	if s[i] == 'i' and f == 2:
		f = 3
	if s[i] == 'd' and f == 3:
		f = 4
	if s[i] == 'i' and f == 4:
		f = 5
		print('YES')
if f < 5:
	print('NO')


checking = 'heidi'
res = 'YES'
l = 0
z = input()
while True and l < 5:
	new = z.find(checking[l])
	if new == -1:
		res = 'NO'
		break
	z = z[new:]
	l += 1
print(res)


a = 'heidi'
s = input()
count = 0
for i in s:
	if i == 'h' and count == 0:
		count += 1
	elif count == 1 and i == 'e':
		count += 1
	elif count == 2 and i == 'i':
		count += 1
	elif count == 3 and i == 'd':
		count += 1
	elif count == 4 and i == 'i':
		count += 1
	else:
		pass
if count == 5:
	print('YES')
else:
	print('NO')


x = input()
check = True
a = ['h', 'e', 'i', 'd', 'i']
for i in range(5):
	p = x.find(a[i])
	y = x[p:]
	x = y
	if p == -1:
		check = False
		break
if check == True:
	print('YES')
else:
	print('NO')


a = iter(input())
print(('NO', 'YES')[all((i in a for i in 'heidi'))])


i = input()
t = 'heidi'
k = 0
flag = 0
for j in i:
	if j == t[k]:
		k = k + 1
	if k == 5:
		flag = 1
		break
if flag == 1:
	print('YES')
else:
	print('NO')


s = input()
h = s.find('h')
s = s[h:]
if 'e' not in s:
	print('NO')
else:
	e = s.find('e')
	s = s[e:]
	if 'i' not in s:
		print('NO')
	else:
		i = s.find('i')
		s = s[i:]
		if 'd' not in s:
			print('NO')
		else:
			d = s.find('d')
			s = s[d:]
			if 'i' not in s:
				print('NO')
			else:
				print('YES')


a = str(input())
a = a + ' '
b = 0
for i in a:
	if b == 5:
		print('YES')
		break
	elif i == ' ':
		print('NO')
		break
	elif b == 0:
		if 'h' in i:
			b += 1
		else:
			b += 0
	elif b == 1:
		if 'e' in i:
			b += 1
		else:
			b += 0
	elif b == 2:
		if 'i' in i:
			b += 1
		else:
			b += 0
	elif b == 3:
		if 'd' in i:
			b += 1
		else:
			b += 0
	elif b == 4:
		if 'i' in i:
			b += 1
		else:
			b += 0