Alice likes word "nineteen" very much. She has a string s and wants the string to contain as many such words as possible. For that reason she can rearrange the letters of the string.

For example, if she has string "xiineteenppnnnewtnee", she can get string "xnineteenppnineteenw", containing (the occurrences marked) two such words. More formally, word "nineteen" occurs in the string the number of times you can read it starting from some letter of the string. Of course, you shouldn't skip letters.

Help her to find the maximum number of "nineteen"s that she can get in her string.


-----Input-----

The first line contains a non-empty string s, consisting only of lowercase English letters. The length of string s doesn't exceed 100.


-----Output-----

Print a single integer — the maximum number of "nineteen"s that she can get in her string.


-----Examples-----
Input
nniinneetteeeenn

Output
2
Input
nneteenabcnneteenabcnneteenabcnneteenabcnneteenabcii

Output
2
Input
nineteenineteen

Output
2

Difficulty: MEDIUM

Solutions:
s = input()
n = s.count('n')
i = s.count('i')
e = s.count('e')
t = s.count('t')
A = []
A.append(i)
A.append(e // 3)
A.append(t)
m = min(A)
if n > m * 3 - (m - 1):
	print(m)
else:
	print(max(0, (n + 1) // (3 - 1) - 1))


S = input()
max_count = 0
letter_dic = {'n': 0, 'i': 0, 'e': 0, 't': 0}
for s in S:
	if s in letter_dic:
		letter_dic[s] += 1
n_count = (letter_dic['n'] - 1) // 2
i_count = letter_dic['i']
e_count = letter_dic['e'] // 3
t_count = letter_dic['t']
ans_num = min(n_count, i_count, e_count, t_count)
if ans_num < 0:
	ans_num = 0
print('%d' % ans_num)


entrada = input()
n = 0
e = 0
i = 0
t = 0
for k in range(len(entrada)):
	if entrada[k] == 'n':
		n += 1
	if entrada[k] == 'e':
		e += 1
	if entrada[k] == 'i':
		i += 1
	if entrada[k] == 't':
		t += 1
if n % 2 == 0:
	n -= 1
n = (n - 3) // 2 + 1
if n == -1:
	n = 0
e = e // 3

def fmenor(a, b, c, d):
	menor: None
	if a <= b and a <= c and (a <= d):
		menor = a
	elif b <= a and b <= c and (b <= d):
		menor = b
	elif c <= d and c <= a and (c <= b):
		menor = c
	else:
		menor = d
	return menor
print(fmenor(n, e, i, t))


s = input().rstrip().lstrip()
print(min(max(0, s.count('n') - 1) // 2, s.count('i'), s.count('e') // 3, s.count('t')))


s = input()
n = i = e = t = 0
for k in range(len(s)):
	if s[k] == 'n':
		n += 1
	elif s[k] == 'i':
		i += 1
	elif s[k] == 'e':
		e += 1
	elif s[k] == 't':
		t += 1
if n == 5:
	print(min(2, i, e // 3, t))
else:
	print(max(0, min((n - 1) // 2, i, e // 3, t)))


p = input()
dic = {'n': 0, 'i': 0, 'e': 0, 't': 0}
for i in p:
	if i in dic:
		dic[i] += 1
qtd_n = 3
if dic['n'] > 3:
	qtd_n = 2
	dic['n'] -= 1
print(min(dic['n'] // qtd_n, dic['i'], dic['t'], dic['e'] // 3))


s = str(input())
s_n = (s.count('n') - 1) // 2
s_i = s.count('i') // 1
s_e = s.count('e') // 3
s_t = s.count('t') // 1
if min((s_n, s_i, s_e, s_t)) <= 0:
	print(0)
else:
	print(min(s_n, s_i, s_e, s_t))


string1 = input()
dict1 = {}
dict2 = {'n': 3, 'i': 1, 'e': 3, 't': 1}
for i in string1:
	if i not in dict1:
		dict1[i] = 0
	dict1[i] += 1
min1 = 0
set1 = set('nineteen')
min1 = 100
if dict1.get('n', None) == None or dict1.get('i', None) == None or dict1.get('e', None) == None or (dict1.get('t', None) == None):
	print(0)
else:
	for i in set1:
		if i == 'n':
			if dict1[i] - 3 >= 0:
				if (dict1[i] - 3) // 2 + 1 < min1:
					min1 = (dict1[i] - 3) // 2 + 1
			else:
				min1 = 0
		elif dict1[i] // dict2[i] < min1:
			min1 = dict1[i] // dict2[i]
	print(int(min1))


c = input().count
print(max(0, min((c('n') - 1) // 2, c('i'), c('e') // 3, c('t'))))


s = input()
n = s.count('n')
i = s.count('i')
e = s.count('e')
t = s.count('t')
print(int(max(min((n + 1) // 2 - 1, e // 3, i, t), 0)))


def solve(l: str):
	n = len([i for i in l if i == 'n'])
	i = len([i for i in l if i == 'i'])
	e = len([i for i in l if i == 'e'])
	t = len([i for i in l if i == 't'])
	ans = 0
	if check(n, i, e, t) == False:
		return 0
	yes = False
	nc = 3
	while n > 0 and i > 0 and (e > 0) and (t > 0):
		if n < nc or i < 1 or e < 3 or (t < 1):
			return ans
		ans += 1
		if yes:
			n -= 2
		else:
			n -= 3
			yes = True
			nc = 2
		i -= 1
		e -= 3
		t -= 1
	return ans

def check(n, i, e, t):
	if n < 3 or i < 1 or e < 3 or (t < 1):
		return False
	return True
s = input()
print(solve(s))


from collections import defaultdict
s = input()
c_map = defaultdict(int)
for c in s:
	c_map[c] += 1
s_map = defaultdict(int)
t = 'nineteen'
mini = float('inf')
for c in t:
	s_map[c] += 1
for c in s_map:
	if c == 'n' and c_map[c] > 2:
		mini = min(mini, (c_map[c] - 1) // 2)
	else:
		mini = min(mini, c_map[c] // s_map[c])
print(mini)


s = input()
count_n = s.count('n')
count_e = s.count('e')
count_i = s.count('i')
count_t = s.count('t')
print(max(0, min((count_n - 1) // 2, count_e // 3, count_i, count_t)))


import math
import cmath
s = input()
n = i = t = e = 0
for a in s:
	if a == 'n':
		n += 1
	if a == 'i':
		i += 1
	if a == 't':
		t += 1
	if a == 'e':
		e += 1
print(max(0, min((n - 1) // 2, e // 3, i, t)))


def nineteen(s):
	(result, d) = ('n' + 'ineteen' * 105, {})
	for elem in result:
		d[elem] = s.count(elem)
	j = 0
	while d[result[j]] > 0:
		d[result[j]] -= 1
		j += 1
	return result[:j].count('ineteen')
print(nineteen(input()))


x = 'niet'
z = []
cadena = input()
for i in x:
	if i == 'i' or i == 't':
		z += [cadena.count(i)]
	elif i == 'n' and cadena.count('n') > 4:
		z += [(cadena.count(i) - 1) // 2]
	else:
		z += [cadena.count(i) // 3]
print(min(z))


str = input()
list = []
n = 0
i = 0
e = 0
t = 0
for k in str:
	if k == 'n':
		n += 1
	elif k == 'i':
		i += 1
	elif k == 'e':
		e += 1
	elif k == 't':
		t += 1
n = (n - 1) / 2
e = e / 3
i = i
t = t
list = [n, i, e, t]
print(int(min(list)))


from math import floor
string = input()
counts_n = floor(string.count('n') / 2)
counts_e = floor(string.count('e') / 3)
counts_i = string.count('i')
counts_t = string.count('t')
result = min(counts_n, counts_e, counts_i, counts_t)
if result > 0 and string.count('n') <= result * 2:
	result -= 1
print(result)


def nineteen(string):
	nineteen_count = dict()
	result = 0
	for i in string:
		if i == 'n' or i == 'e' or i == 'i' or (i == 't'):
			if i not in nineteen_count:
				nineteen_count[i] = 1
			else:
				nineteen_count[i] += 1
	try:
		while nineteen_count['e'] >= 3 and nineteen_count['i'] >= 1 and (nineteen_count['t'] >= 1):
			if result > 0:
				if nineteen_count['n'] >= 2:
					nineteen_count['n'] -= 2
					nineteen_count['e'] -= 3
					nineteen_count['i'] -= 1
					nineteen_count['t'] -= 1
					result += 1
				else:
					break
			elif nineteen_count['n'] >= 3:
				nineteen_count['n'] -= 3
				nineteen_count['e'] -= 3
				nineteen_count['i'] -= 1
				nineteen_count['t'] -= 1
				result += 1
			else:
				break
	except:
		pass
	return result
string = input()
print(nineteen(string))


import math
s = input()
print(max(0, min((s.count('n') - 1) // 2, s.count('i'), s.count('t'), s.count('e') // 3)))


import math
s = input()
dic = {}
if 'n' not in s or 'i' not in s or 'e' not in s or ('t' not in s):
	print(0)
else:
	for i in s:
		if i in dic:
			dic[i] += 1
		else:
			dic[i] = 1
	n = math.floor(dic['n'])
	e = math.floor(dic['e'] / 3)
	i = dic['i']
	t = dic['t']
	temp = min([e, i, t])
	if n > 3 * temp - temp:
		print(temp)
	else:
		n = n - 3
		if n < 0:
			print(0)
		else:
			print(1 + int(n / 2))


a = str(input())
i = [0]
n = [0]
t = [0]
e = [0]
for x in a:
	x = str(x)
	if x == 'i':
		i[0] += 1
	if x == 'n':
		n[0] += 1
	if x == 't':
		t[0] += 1
	if x == 'e':
		e[0] += 1
i_m = i[0]
e_m = e[0] // 3
t_m = t[0]
n_m = 0
if n[0] >= 3:
	n[0] -= 3
	n_m += 1
	n_m += n[0] // 2
print(min(i_m, n_m, e_m, t_m))


import sys
a = input()
a = list(a)
n = 0
n = a.count('n')
i = 0
i = a.count('i')
t = 0
t = a.count('t')
e = 0
e = a.count('e')
if n < 3:
	print(0)
	sys.exit()
if i < 1:
	print(0)
	sys.exit()
if t < 1:
	print(0)
	sys.exit()
if e < 3:
	print(0)
	sys.exit()
ans = 0
while n >= 3 and e >= 3 and (t >= 1) and (i >= 1):
	n -= 2
	e -= 3
	t -= 1
	i -= 1
	ans += 1
print(ans)


t = input()
temp = {'n': 0, 'i': 0, 'e': 0, 't': 0}
for l in t:
	if l in temp:
		temp[l] += 1
temp['n'] = temp['n'] - 1 if temp['n'] > 3 else temp['n']
counts = {'n': 2 if temp['n'] > 3 else 3, 'i': 1, 'e': 3, 't': 1}
print(min([int(temp[k] / counts[k]) for k in temp]))


s = input()
l = list(s)
ic = 0
nc = 0
ec = 0
tc = 0
nineteen = 0
for i in l:
	if i == 'i':
		ic = ic + 1
	elif i == 'n':
		nc = nc + 1
	elif i == 'e':
		ec = ec + 1
	elif i == 't':
		tc = tc + 1
	else:
		continue
while 1:
	if nc > 2:
		if ec >= 3 and tc >= 1 and (ic >= 1):
			nineteen = nineteen + 1
			ec = ec - 3
			tc = tc - 1
			ic = ic - 1
			nc = nc - 2
		else:
			break
	else:
		break
print(nineteen)


s = input()
n = (s.count('n') - 1) // 2
if n < 0:
	n = 0
i = s.count('i')
e = s.count('e') // 3
t = s.count('t')
print(min(n, i, e, t))


from collections import defaultdict
s = input()
d = defaultdict(int)
for i in range(len(s)):
	d[s[i]] += 1
print(min(max(d['n'] - 3, 0) // 2 + (d['n'] >= 3), d['i'], d['e'] // 3, d['t']))


s = input()
a = s.count('n')
b = s.count('e')
c = s.count('i')
d = s.count('t')
ans = min(int((a - 1) / 2), int(b / 3), int(c), int(d))
print(ans)


s = input()

def count(s, char):
	return len([x for x in list(s) if x == char])
n = count(s, 'n')
i = count(s, 'i')
e = count(s, 'e')
t = count(s, 't')
print(max(0, min((n - 1) // 2, e // 3, i, t)))


a = input().strip()
num_n = a.count('n')
num_e = a.count('e')
num_i = a.count('i')
num_t = a.count('t')
num_n = int((num_n - 1) / 2)
num_e = int(num_e / 3)
print(min(num_n, num_e, num_i, num_t))


s = input()
d = {}
for i in range(26):
	d[chr(i + 97)] = s.count(chr(i + 97))
ans = 0
if d['n'] >= 3 and d['e'] >= 3 and (d['i'] >= 1) and (d['t'] >= 1):
	ans += 1
	d['n'] -= 3
	d['e'] -= 3
	d['i'] -= 1
	d['t'] -= 1
if ans > 0:
	while d['n'] >= 2 and d['e'] >= 3 and (d['i'] >= 1) and (d['t'] >= 1):
		ans += 1
		d['n'] -= 2
		d['e'] -= 3
		d['i'] -= 1
		d['t'] -= 1
print(ans)


def fun(s):
	bs = {'n': 3, 'i': 1, 'e': 3, 't': 1}
	d = dict()
	crr = 100000
	for i in s:
		if i in d:
			d[i] += 1
		else:
			d[i] = 1
	for i in bs:
		if i not in d:
			return 0
		if i != 'n':
			if d[i] == 0 or d[i] / bs[i] == 0:
				return 0
			else:
				crr = min(crr, d[i] // bs[i])
	if 'n' in d:
		crr = min(crr, (d['n'] - 1) // 2)
	return crr
x = input()
print(fun(x))


a = {'n': 0, 't': 0, 'i': 0, 'e': 0}
nineteen = {'n': 3, 't': 1, 'i': 1, 'e': 3}
a_keys = ['n', 'i', 't', 'e']
strinput = input().lower()
for i in list(strinput):
	if i in a_keys:
		a[i] += 1
output = 0
end = False
while True:
	for i in nineteen:
		if a[i] >= nineteen[i]:
			a[i] -= nineteen[i]
		else:
			end = True
			break
	if end:
		break
	output += 1
	a['n'] += 1
print(output)


char_count = {}
for c in input():
	if c not in char_count:
		char_count[c] = 1
	else:
		char_count[c] += 1
try:
	n = char_count['n']
	e = char_count['e']
	i = char_count['i']
	t = char_count['t']
	if n >= e:
		print(min(e // 3, i, t))
	else:
		x = (n - 1) // 2
		print(min(x, e // 3, i, t))
except:
	print(0)


from collections import Counter
s = input()
m = Counter(s)
if m['n'] < 3:
	print(0)
else:
	print(min((m['n'] - 1) // 2, m['e'] // 3, m['t'], m['i']))


searchWord = 'nineteen'
word = input()
count = {}
for ch in list(set(list(searchWord))):
	if ch == 'n':
		if word.count('n') >= 3:
			count[ch] = (word.count(ch) - 3) // 2
			count[ch] += 1
		else:
			count[ch] = 0
	else:
		count[ch] = word.count(ch) // searchWord.count(ch)
print(min(list(count.values())))


n = 0
i = 0
e = 0
t = 0
count = 0
a = input()
for j in list(a):
	if j == 'n':
		n += 1
	elif j == 'i':
		i += 1
	elif j == 'e':
		e += 1
	elif j == 't':
		t += 1
	if n >= 3 and i >= 1 and (e >= 3) and (t >= 1):
		count += 1
		n -= 2
		i -= 1
		e -= 3
		t -= 1
print(count)


z = input()
(a, b, c, d) = (0, 0, 0, 0)
for x in z:
	if x == 'n':
		a = a + 1
	if x == 'i':
		b = b + 1
	if x == 't':
		c = c + 1
	if x == 'e':
		d = d + 1
t = 0
k = min(b, c)
if k != 0:
	for i in range(k):
		if (a + k - i - 1) // (k - i) >= 3 and d // (k - i) >= 3:
			print(k - i)
			t = t + 1
			break
	if t == 0:
		print(t)
else:
	print(0)


s = input()
d = {'n': 0, 'i': 0, 'e': 0, 't': 0}
a = ['n', 'i', 'e', 't']
c = []
for x in s:
	if x in a:
		c.append(x)
for i in c:
	d[i] += 1
ans = 0
p = True
while p:
	k = 1
	for x in d:
		if x == 'n':
			if d[x] >= 3:
				d[x] -= 2
				if d[x] == 0:
					p = False
			else:
				p = False
				k = 0
				break
		elif x == 'e':
			if d[x] >= 3:
				d[x] -= 3
				if d[x] == 0:
					p = False
			else:
				p = False
				k = 0
				break
		elif d[x] >= 1:
			d[x] -= 1
			if d[x] == 0:
				p = False
		else:
			p = False
			k = 0
			break
	ans += k
print(ans)


def v_19(s):
	a = [0, 0, 0, 0]
	for i in range(len(s)):
		if s[i] == 'n':
			a[0] += 1
		elif s[i] == 'i':
			a[2] += 1
		elif s[i] == 'e':
			a[1] += 1
		elif s[i] == 't':
			a[3] += 1
	return a
s = input()
q = v_19(s)
if q[0] < 5:
	q[0] = q[0] // 3
else:
	q[0] = (q[0] - 1) // 2
q[1] = q[1] // 3
print(min(q))


word = input()
res = 0
a = [0] * 4
for i in range(len(word)):
	if word[i] == 'n':
		a[0] += 1
	elif word[i] == 'i':
		a[1] += 1
	elif word[i] == 'e':
		a[2] += 1
	elif word[i] == 't':
		a[3] += 1
a[2] = a[2] // 3
a[0] = (a[0] - 1) // 2
a.sort()
if a[0] < 0:
	print(0)
else:
	print(a[0])


NUMBER_N = 3
NUMBER_I = 1
NUMBER_E = 3
NUMBER_T = 1

def main():
	text = input()
	nN = text.count('n')
	nI = text.count('i')
	nE = text.count('e')
	nT = text.count('t')
	fI = int(nI / NUMBER_I)
	fE = int(nE / NUMBER_E)
	fT = int(nT / NUMBER_T)
	count = min(fI, fE, fT)
	fN = int((nN - 1) / 2)
	count = min(fN, count)
	print(count)
main()


str = list(input())
cntN = max((str.count('n') - 3) // 2 + 1, 0)
cntI = max(str.count('i') // 1, 0)
cntE = max(str.count('e') // 3, 0)
cntT = max(str.count('t') // 1, 0)
print(min(cntN, cntI, cntE, cntT))


def solve(text):
	count = {'n': 0, 'i': 0, 'e': 0, 't': 0}
	for l in text:
		if l in count:
			count[l] += 1
	return max(min([count['i'], (count['n'] - 1) // 2, count['e'] // 3, count['t']]), 0)

def main():
	text = input()
	print(solve(text))
main()


s = input()

def f(s):
	n = 0
	i = 0
	e = 0
	t = 0
	for j in s:
		if j == 'n':
			n += 1
		elif j == 'i':
			i += 1
		elif j == 'e':
			e += 1
		elif j == 't':
			t += 1
	_n = n // 2
	e = e // 3
	min_ = min(_n, i, e, t)
	r = n - min_ * 2
	if min_ <= 0:
		print(0)
		return
	if r == 0:
		print(min_ - 1)
	else:
		print(min_)
f(s)


from collections import Counter
s = input()
l = Counter(s)
num = 0
check = 1
for i in s:
	if i == 'n':
		check = 0
		if l['i'] < 1 or l['t'] < 1 or l['e'] < 3 or (l['n'] < 3):
			print(num)
			break
		l['i'] -= 1
		l['t'] -= 1
		l['n'] -= 2
		l['e'] -= 3
		num += 1
if check == 1:
	print(num)


def nineteen(string_str) -> int:
	letter_count_dict = dict()
	for letter in string_str:
		if letter_count_dict.get(letter, 0) == 0:
			letter_count_dict[letter] = 1
		else:
			letter_count_dict[letter] += 1
	nineteen_count = 0
	while letter_count_dict.get('n', 0) >= 3 and letter_count_dict.get('i', 0) >= 1 and (letter_count_dict.get('e', 0) >= 3) and (letter_count_dict.get('t', 0) >= 1):
		letter_count_dict['n'] -= 2
		letter_count_dict['i'] -= 1
		letter_count_dict['e'] -= 3
		letter_count_dict['t'] -= 1
		nineteen_count += 1
	return nineteen_count

def __starting_point():
	string = input()
	print(nineteen(string))
__starting_point()


s = input('')
count = 0
n = 0
i = 0
e = 0
t = 0
for j in s:
	if j == 'n':
		n += 1
	elif j == 'i':
		i += 1
	elif j == 'e':
		e += 1
	elif j == 't':
		t += 1
if n >= 3 and i >= 1 and (t >= 1) and (e >= 3):
	c = True
	n = n - 3
	i = i - 1
	t = t - 1
	e = e - 3
	count += 1
	while c != False:
		n = n - 2
		i = i - 1
		t = t - 1
		e = e - 3
		if n < 0 or i < 0 or t < 0 or (e < 0):
			c = False
		else:
			count += 1
print(count)


Allsymbols = input()
AllNs = 0
AllEs = 0
AllIs = 0
AllTs = 0
for ch in Allsymbols:
	if ch == 'n':
		AllNs += 1
	elif ch == 'e':
		AllEs += 1
	elif ch == 'i':
		AllIs += 1
	elif ch == 't':
		AllTs += 1
l = 0
r = 100

def Do(m):
	return 3 + (m - 1) * 2 <= AllNs and m * 3 <= AllEs and (m <= AllIs) and (m <= AllTs)
while l <= r:
	m = (l + r) // 2
	S = Do(m)
	if S:
		l = m + 1
	else:
		r = m - 1
if not Do(m) and Do(m - 1):
	m = m - 1
if m == -1:
	m = 0
print(m)


def sol(s):
	if not s:
		return 0
	count = {}
	count2 = {}
	for c in s:
		count[c] = count.get(c, 0) + 1
	for c in 'nineteen':
		count2[c] = count2.get(c, 0) + 1
	k = 0
	while True:
		if k >= 1:
			count2['n'] = 2
		for x in count2:
			if x in count:
				count[x] -= count2[x]
				if count[x] < 0:
					return k
			else:
				return 0
		k += 1
	return k

def canSub(count, count2):
	print('1')
	print(count)
	for x in count2:
		count[x] -= count[2]
		if count[x] <= 0:
			return False
	return True
from collections import Counter
s = input()
print(sol(s))


s = input()
nn = 0
ni = 0
nt = 0
ne = 0
for each in s:
	if each == 'n':
		nn += 1
	elif each == 't':
		nt += 1
	elif each == 'i':
		ni += 1
	elif each == 'e':
		ne += 1
nn -= 1
nn //= 2
ne //= 3
res = min(nn, ne, nt, ni)
if res >= 0:
	print(res)
else:
	print(0)


s = input()
a = s.count('n')
b = s.count('i')
c = s.count('e')
d = s.count('t')
e = min(b, c // 3, d)
print(min(e, max((a - 1) // 2, 0)))


string = input()
mylist = []
i = 0
mylist.append((string.count('n') - 1) / 2)
mylist.append(string.count('e') / 3)
mylist.append(string.count('i'))
mylist.append(string.count('t'))
print(int(min(mylist)) + i)


my_dict = {'n': [], 'e': [], 'i': [], 't': []}
i = 0
s = input()
for c in s:
	if c in my_dict:
		my_dict[c].append(c)
my_bool = True
while my_bool:
	try:
		if my_dict['n'].pop() + my_dict['i'].pop() + my_dict['n'].pop() + my_dict['e'].pop() + my_dict['t'].pop() + my_dict['e'].pop() + my_dict['e'].pop() + my_dict['n'].pop() == 'nineteen':
			i += 1
			if len(my_dict['n']) != 0:
				my_dict['n'] += 'n'
			else:
				my_bool = False
		else:
			my_bool = False
	except:
		my_bool = False
print(i)


from math import floor

def count_nineteen(string):
	n = string.count('n')
	i = string.count('i')
	e = string.count('e')
	t = string.count('t')
	contar_n = floor(n / 3)
	if contar_n < floor((n - 1) / 2):
		contar_n = floor((n - 1) / 2)
	print(min(contar_n, floor(i / 1), floor(e / 3), floor(t / 1)))
palabra = input()
count_nineteen(palabra)


x = input()
n = 0
i = 0
e = 0
t = 0
for j in x:
	if j == 'n':
		n += 1
	if j == 'i':
		i += 1
	if j == 'e':
		e += 1
	if j == 't':
		t += 1
z = []
z.append(int((n - 1) / 2))
z.append(i)
z.append(int(e / 3))
z.append(t)
print(min(z))


s = input()
k = s
l = s
d = s
r = s
k = k.replace('n', '')
l = l.replace('i', '')
d = d.replace('t', '')
r = r.replace('e', '')
(n, i, t, e) = (0, 0, 0, 0)
n = len(s) - len(k)
i = len(s) - len(l)
t = len(s) - len(d)
e = len(s) - len(r)
x = 0
if n - 3 >= 0 and i - 1 >= 0 and (t - 1 >= 0) and (e - 3 >= 0):
	g = 'nineteen'
	n -= 3
	i -= 1
	t -= 1
	e -= 3
	x += 1
	while n - 2 >= 0 and i - 1 >= 0 and (t - 1 >= 0) and (e - 3 >= 0):
		n -= 2
		i -= 1
		t -= 1
		e -= 3
		x += 1
print(x)


b = input()
a = list(b)
n = a.count('n')
if n > 3:
	n += int(n / 3)
if n > 9:
	n += int(n / 9)
n = int(n / 3)
i = a.count('i')
e = int(a.count('e') / 3)
t = a.count('t')
if e <= i and e <= n and (e <= t):
	print(e)
elif n <= i and n <= e and (n <= t):
	print(n)
elif i <= n and i <= e and (i <= t):
	print(i)
elif t <= i and t <= e and (t <= n):
	print(t)


s = input()
map_ = {'n': 0, 'i': 0, 'e': 0, 't': 0}
for ch in s:
	if ch in map_.keys():
		map_[ch] += 1
ans = map_['i']
ans = min(ans, map_['t'])
ans = min(ans, (map_['n'] - 1) / 2)
ans = min(ans, map_['e'] / 3)
print(int(ans))


str = input()
array = [0, 0, 0, 0]
for i in range(len(str)):
	if str[i] == 'n':
		array[0] += 1
	elif str[i] == 'i':
		array[1] += 1
	elif str[i] == 'e':
		array[2] += 1
	elif str[i] == 't':
		array[3] += 1
if array[0] < 3 or array[1] < 1 or array[2] < 3 or (array[3] < 1):
	print('0')
else:
	sum = 1
	array[0] -= 3
	array[1] -= 1
	array[2] -= 3
	array[3] -= 1
	while array[0] >= 2 and array[1] >= 1 and (array[2] >= 3) and (array[3] >= 1):
		array[0] -= 2
		array[1] -= 1
		array[2] -= 3
		array[3] -= 1
		sum += 1
	print(sum)


x = input()
a = x.count('n')
b = x.count('i')
c = x.count('e')
d = x.count('t')
if a >= 5:
	a -= 1
	a /= 2
else:
	a /= 3
c /= 3
a = int(a)
c = int(c)
i = 0
while a > 0 and b > 0 and (c > 0) and (d > 0):
	i += 1
	a -= 1
	b -= 1
	c -= 1
	d -= 1
print(i)


(n, c) = (input(), 0)
nc = n.count('n')
if nc >= 3:
	c = 1
	nc -= 3
	print(min(nc // 2 + c, n.count('i'), n.count('t'), n.count('e') // 3))
else:
	print('0')


import sys
from collections import Counter
c_counts = {'n': 2, 'i': 1, 'e': 3, 't': 1}

def count_nineteens(s):
	min_possible = sys.maxsize
	s_c_counts = Counter(s)
	if s_c_counts['n'] > 0:
		s_c_counts['n'] -= 1
	for (c, count) in c_counts.items():
		possible = s_c_counts[c] // c_counts[c]
		min_possible = min(min_possible, possible)
	if min_possible == sys.maxsize:
		return 0
	return min_possible

def main():
	s = input()
	print(count_nineteens(s))
main()


from collections import Counter as C
s = input()
n = {'n': lambda x: (x - 1) // 2 if (x - 1) // 2 >= 0 else 0, 'i': lambda x: x, 't': lambda x: x, 'e': lambda x: x // 3}
ans = C(s)
l = [n[i](ans[i]) for i in n]
print(min(l))


def solve(s):
	return 0 if s.count('n') == 0 else min((s.count('n') - 1) // 2, s.count('i'), s.count('e') // 3, s.count('t'))

def main():
	arr2 = input()
	print(solve(arr2))
main()


import sys
import unittest

class Tests(unittest.TestCase):

	def test1(self):
		f1 = open('tests/1.txt', 'r')
		f2 = open('tests/1a.txt', 'r')
		sys.stdin = f1
		self.assertEqual(main(), int(f2.read().strip()), 'test №1')
		f1.close()
		f2.close()

	def test2(self):
		f1 = open('tests/2.txt', 'r')
		f2 = open('tests/2a.txt', 'r')
		sys.stdin = f1
		self.assertEqual(main(), int(f2.read().strip()), 'test №2')
		f1.close()
		f2.close()

	def test3(self):
		f1 = open('tests/3.txt', 'r')
		f2 = open('tests/3a.txt', 'r')
		sys.stdin = f1
		self.assertEqual(main(), int(f2.read().strip()), 'test №3')
		f1.close()
		f2.close()

def main():
	st = input()
	con_n = 0
	con_e = 0
	con_t = 0
	con_i = 0
	for i in st:
		if i == 'n':
			con_n += 1
		elif i == 'e':
			con_e += 1
		elif i == 't':
			con_t += 1
		elif i == 'i':
			con_i += 1
	if con_n == 0:
		return 0
	return min((con_n - 1) // 2, con_e // 3, con_t, con_i)
print(main())


a = list(input())
n = a.count('n')
i = a.count('i')
e = a.count('e')
t = a.count('t')
if n == 0:
	q = 0
else:
	q = min((n - 1) // 2, i, t, e // 3)
print(q)


s = input()
arr = [0] * 4
for i in s:
	if i == 'n':
		arr[0] += 1
	elif i == 'e':
		arr[1] += 1
	elif i == 'i':
		arr[2] += 1
	elif i == 't':
		arr[3] += 1
arr[0] = (arr[0] - 1) // 2
arr[1] = arr[1] // 3
if arr[0] < 0:
	print(0)
else:
	print(min(arr))


def nineteen(string):
	d19 = {x: 0 for x in 'niet'}
	for x in string:
		if x in 'niet':
			d19[x] += 1
	return int(min([(d19['n'] - 1) / 2, d19['i'], d19['e'] / 3, d19['t']]))
print(nineteen(input()))


__author__ = 'Obriel Muga'

def nineteen(s):
	n = 0
	i = 0
	e = 0
	t = 0
	for letra in s:
		if letra == 'n':
			n = n + 1
		elif letra == 'i':
			i = i + 1
		elif letra == 'e':
			e = e + 1
		elif letra == 't':
			t = t + 1
	if n < 3:
		n = int(n / 3)
	else:
		n = int((n - 3) / 2) + 1
	i = int(i)
	t = int(t)
	e = int(e / 3)
	return min([n, i, e, t])
s = str(input())
print(nineteen(s))


targetWord = 'nineteen'
letterDictionary = {}
for letter in targetWord:
	if letter in letterDictionary:
		letterDictionary[letter] = letterDictionary[letter] + 1
	else:
		letterDictionary[letter] = 1
inputDataDictionary = {}
inputString = input()
for letter in inputString:
	if letter in letterDictionary.keys():
		if letter in inputDataDictionary:
			inputDataDictionary[letter] = inputDataDictionary[letter] + 1
		else:
			inputDataDictionary[letter] = 1
result = 100
for letter in letterDictionary.keys():
	if targetWord[0] != targetWord[len(targetWord) - 1] or targetWord[0] != letter:
		if letter in inputDataDictionary:
			result = min(result, inputDataDictionary[letter] // letterDictionary[letter])
		else:
			result = 0
			break
if targetWord[0] == targetWord[len(targetWord) - 1]:
	if targetWord[0] not in inputDataDictionary or inputDataDictionary[targetWord[0]] < letterDictionary[targetWord[0]]:
		result = 0
	else:
		temp = inputDataDictionary[targetWord[0]]
		temp = temp - letterDictionary[targetWord[0]]
		temp = 1 + temp // (letterDictionary[targetWord[0]] - 1)
		result = min(temp, result)
print(result)


f = input()

def count(s):
	(n, i, e, t) = (0, 0, 0, 0)
	for v in s:
		if v == 'n':
			n += 1
		if v == 'i':
			i += 1
		if v == 'e':
			e += 1
		if v == 't':
			t += 1
	if n == 0:
		print(0)
	else:
		n = (n - 1) // 2
		e = e // 3
		print(min(n, i, e, t))
if len(f) <= 100 and len(f) > 0:
	count(f)
else:
	pass


n = 0
e = 0
t = 0
i = 0
word = input()
for l in range(len(word)):
	if word[l] == 'n':
		n += 1
	if word[l] == 'e':
		e += 1
	if word[l] == 't':
		t += 1
	if word[l] == 'i':
		i += 1
n -= 1
print(max(min(min(int(n / 2), int(e / 3)), min(i, t)), 0))


x = input()
dic = {'n': 0, 'i': 0, 't': 0, 'e': 0}
for i in x:
	if i == 'n':
		dic['n'] += 1
	if i == 'i':
		dic['i'] += 1
	if i == 'e':
		dic['e'] += 1
	if i == 't':
		dic['t'] += 1
cont = 0
if dic['n'] > 2:
	while (dic['n'] >= 3 or dic['n'] == 2) and dic['i'] >= 1 and (dic['t'] >= 1) and (dic['e'] >= 3):
		if cont > 0:
			dic['n'] -= 2
		else:
			dic['n'] -= 3
		dic['i'] -= 1
		dic['t'] -= 1
		dic['e'] -= 3
		cont += 1
print(cont)


s = str(input())
(rn, ri, rt, re) = (0, 0, 0, 0)
for char in s:
	if char == 'n':
		rn += 1
	if char == 'i':
		ri += 1
	if char == 't':
		rt += 1
	if char == 'e':
		re += 1
if rn != 0:
	rn = rn - 3
	rn = rn // 2 + 1
re = re // 3
print(min(rn, ri, rt, re))


inp = input()
(n, i, e, t) = (0, 0, 0, 0)
for j in range(len(inp)):
	if inp[j] == 'n':
		n += 1
	elif inp[j] == 'i':
		i += 1
	elif inp[j] == 'e':
		e += 1
	elif inp[j] == 't':
		t += 1
nby3 = (n - 1) // 2
eby3 = e // 3
res = 0
new = ''
while nby3 > 0 and i > 0 and (eby3 > 0) and (t > 0):
	res += 1
	nby3 -= 1
	i -= 1
	eby3 -= 1
	t -= 1
print(res)


niet = [0, 0, 0, 0]
string = input()
count = 0
if count == 0:
	for i in string:
		if i == 'n':
			niet[0] += 1
		elif i == 'i':
			niet[1] += 1
		elif i == 'e':
			niet[2] += 1
		elif i == 't':
			niet[3] += 1
	niet[0] = int((niet[0] / 2 - 0.5) // 1)
	niet[2] //= 3
	m = min(niet)
	if m == -1:
		print(0)
	else:
		print(m)
else:
	print(count)


s = input()
l = list(s)
i = 0
count = 0
while i < len(l):
	if 'n' in l:
		l.remove('n')
		if 'i' in l:
			l.remove('i')
			if 'n' in l:
				l.remove('n')
				if 'e' in l:
					l.remove('e')
					if 't' in l:
						l.remove('t')
						if 'e' in l:
							l.remove('e')
							if 'e' in l:
								l.remove('e')
								if 'n' in l:
									count = count + 1
	else:
		break
print(count)


from collections import Counter
input_str = input()
count = Counter(input_str)
n = 0 if count['n'] <= 2 else 1 + int((count['n'] - 3) / 2)
e = int(count['e'] / 3)
max_ne = n if n < e else e
max_it = count['i'] if count['i'] < count['t'] else count['t']
max_count = max_it if max_it < max_ne else max_ne
print(max_count)


def find(s, c):
	n = 0
	for i in range(len(s)):
		if s[i] == c:
			n += 1
	return n
s = input()
n = find(s, 'n')
i = find(s, 'i')
e = find(s, 'e')
t = find(s, 't')
m = int(min(min((n - 1) / 2, e / 3), min(i, t)))
print(m)


s = input()
let_n = (s.count('n') - 1) // 2
let_i = s.count('i')
let_e = s.count('e') // 3
let_t = s.count('t')
print(max(min(let_i, let_t, let_n, let_e), 0))


s = input()
n = len(s)
nc = 0
ic = 0
ec = 0
tc = 0
for i in range(n):
	if s[i] == 'n':
		nc += 1
	elif s[i] == 'i':
		ic += 1
	elif s[i] == 'e':
		ec += 1
	elif s[i] == 't':
		tc += 1
print(min([int(nc / 3) if nc <= 3 else 1 + int((nc - 3) / 2), ic, int(ec / 3), tc]))


bot = True
s = 'n' + 'ineteen' * 100
x = input()
d = {}
for i in s:
	d[i] = x.count(i)
j = 0
while d[s[j]] > 0:
	d[s[j]] -= 1
	j += 1
print(s[:j].count('ineteen'))


s = input()
m = min(s.count('i'), s.count('e') // 3, s.count('t'))
while m and s.count('n') >= 3:
	if s.count('n') >= m * 3 - (m - 1):
		print(m)
		break
	m -= 1
else:
	print('0')


def countPossibleWord(text):
	t = count_char(text, 't')
	i = count_char(text, 'i')
	base = min([t, i])
	while 1:
		if base == 0:
			return 0
		e = count_char(text, 'e')
		n = count_char(text, 'n')
		if not e >= base * 3:
			base = base - 1
			continue
		elif not n >= base * 2 + 1:
			base = base - 1
			continue
		else:
			return base

def count_char(strin, ch):
	count = 0
	for i in strin:
		if i == ch:
			count += 1
	return count
inp = input()
print(countPossibleWord(inp))


import sys
line = sys.stdin.readline()
word = line.split()[0]
n = 0
i = 0
e = 0
t = 0
for c in word:
	if c == 'n':
		n += 1
	elif c == 'i':
		i += 1
	elif c == 'e':
		e += 1
	elif c == 't':
		t += 1
N = max(0, (n - 1) // 2)
I = i
E = max(0, e // 3)
T = t
print(min([N, I, E, T]))


s = input()
(n, i, e, t) = (s.count('n') - 3, s.count('i') - 1, s.count('e') - 3, s.count('t') - 1)
count = 0
while n >= 0 and i >= 0 and (e >= 0) and (t >= 0):
	count += 1
	(n, i, e, t) = (n - 2, i - 1, e - 3, t - 1)
print(count)


word = input()
nineteen = ['n', 'i', 'e', 't']
occurencies = {}
for letter in nineteen:
	occurencies[letter] = word.count(letter)
occurencies['e'] = int(occurencies['e'] / 3)
occurencies['n'] = int((occurencies['n'] - 1) / 2)
minimo = min(occurencies, key=occurencies.get)
print(occurencies[minimo])


s = input()
n = s.count('n')
i = s.count('i')
e = s.count('e')
t = s.count('t')
c = 0
e = e / 3
p = (n - 1) / 2
print(int(min(p, min(i, min(e, t)))))


s = input()
n = 0
i = 0
e = 0
t = 0
for j in s:
	if j == 'n':
		n += 1
	if j == 'e':
		e += 1
	if j == 't':
		t += 1
	if j == 'i':
		i += 1
ans = 0
while n >= 3 and i >= 1 and (t >= 1) and (e >= 3):
	n -= 3
	i -= 1
	t -= 1
	e -= 3
	if i >= 1 and t >= 1 and (e >= 3):
		n += 1
	ans += 1
print(ans)


n = input()
counts = {'n': 0, 'i': 0, 'e': 0, 't': 0}
for c in n:
	if c in counts:
		counts[c] = counts[c] + 1
numI = int(counts['i'] / 1)
numE = int(counts['e'] / 3)
numT = int(counts['t'] / 1)
resp = 100
if numI < resp:
	resp = numI
if numE < resp:
	resp = numE
if numT < resp:
	resp = numT
numN = 0
if resp < 2:
	numN = int(counts['n'] / 3)
else:
	numN = int(1 + (counts['n'] - 3) / 2)
if numN < resp:
	resp = numN
print(resp)


s = input()
n = s.count('n')
i = s.count('i')
e = s.count('e')
t = s.count('t')
if n >= 5:
	n -= 3
	maxn = 1
	maxn += n // 2
elif n >= 3:
	maxn = 1
else:
	maxn = 0
print(min(maxn, i, e // 3, t))


te = input()
e = 0
i = 0
n = 0
t = 0
for j in te:
	if j == 'e':
		e += 1
	elif j == 'i':
		i += 1
	elif j == 'n':
		n += 1
	elif j == 't':
		t += 1
if n > 3:
	n = 1 + (n - 3) // 2
else:
	n = n // 3
print(min(e // 3, t, i, n))


s = input()
dic = {}
for i in ['n', 'e', 'i', 't']:
	dic[i] = s.count(i)
ans = min(dic['t'], dic['i'])
ans = min((dic['n'] - 1) // 2, ans)
ans = min(ans, dic['e'] // 3)
print(max(0, ans))


def values():
	word = input()
	array = [0, 0, 0, 0]
	for i in word:
		if i == 'n':
			array[0] += 1
		if i == 'i':
			array[1] += 1
		if i == 't':
			array[2] += 1
		if i == 'e':
			array[3] += 1
	return array

def nineteen():
	array = values()
	cont = 0
	if array[0] >= 3 and array[3] >= 3 and (array[1] >= 1) and (array[2] >= 1):
		cont = 1
		array[0] -= 3
		array[1] -= 1
		array[2] -= 1
		array[3] -= 3
		while array[3] >= 3:
			if array[0] >= 2 and array[1] >= 1 and (array[2] >= 1):
				cont += 1
				array[0] -= 2
				array[1] -= 1
				array[2] -= 1
			array[3] -= 3
	return cont
print(nineteen())


import math
s = input()
size = len(s)
letters = [0, 0, 0, 0]
n = 0
i = 0
e = 0
t = 0
for x in range(0, size):
	if s[x] == 'n':
		n += 1
	elif s[x] == 'i':
		i += 1
	elif s[x] == 'e':
		e += 1
	elif s[x] == 't':
		t += 1
if n == 3:
	n = 1
elif n < 3:
	n = 0
else:
	n -= 3
	n = math.floor(n / 2)
	n += 1
e = math.floor(e / 3)
letters[0] = n
letters[1] = i
letters[2] = e
letters[3] = t
print(min(letters))


s = input()
count = {'n': 0, 'i': 0, 'e': 0, 't': 0}
for char in s:
	if char in count.keys():
		count[char] += 1
m = 1000000000
a = []
if m > int((count['n'] - 3) / 2 + 1):
	m = int((count['n'] - 3) / 2 + 1)
if m > count['i']:
	m = count['i']
if m > int(count['e'] / 3):
	m = int(count['e'] / 3)
if m > count['t']:
	m = count['t']
print(m)


s = 'ninetee' * 15
a = list(input())
n = len(a)
i = j = 0
f = 1
while i < n and f:
	f = 0
	for j in range(i, n):
		if a[j] == s[i]:
			(a[j], a[i]) = (a[i], a[j])
			f = 1
	if f:
		i += 1
print([0, (i - 1) // 7][i > 0])


s = 0
l = list(input())
t = l.count('t')
i = l.count('i')
n = l.count('n')
e = l.count('e')
n1 = 0
if n // 3 >= 1:
	n1 = 1 + (n - 3) // 2
else:
	n1 = n // 3
s = min([n1, i, t, e // 3])
print(s)


s = str(input())
x = [0, 0, 0, 0]
ct = 0
i = 1
x[0] = s.count('n')
x[1] = s.count('i')
x[2] = s.count('e')
x[3] = s.count('t')
while 1:
	if i == 1:
		x[0] -= 3
		i = 2
	else:
		x[0] -= 2
	x[1] -= 1
	x[2] -= 3
	x[3] -= 1
	if x[0] >= 0 and x[1] >= 0 and (x[2] >= 0) and (x[3] >= 0):
		ct += 1
	else:
		break
print(ct)


def nineteen(s: str) -> int:
	freq = {c: 0 for c in 'nineteen'}
	for c in s:
		if c in freq:
			freq[c] += 1
	res = 0
	if freq['n'] >= 3 and freq['i'] >= 1 and (freq['e'] >= 3) and (freq['t'] >= 1):
		res += 1
		freq['n'] -= 3
		freq['i'] -= 1
		freq['e'] -= 3
		freq['t'] -= 1
		while freq['n'] >= 2 and freq['i'] >= 1 and (freq['e'] >= 3) and (freq['t'] >= 1):
			freq['n'] -= 2
			freq['i'] -= 1
			freq['e'] -= 3
			freq['t'] -= 1
			res += 1
	return res
s = input()
ans = nineteen(s)
print(ans)


obj = 'nineteen'
(qn, qi, qe, qt) = [0] * 4
for i in input():
	if i == 'n':
		qn += 1
	elif i == 'i':
		qi += 1
	elif i == 'e':
		qe += 1
	elif i == 't':
		qt += 1
if qn >= 3:
	er = 1 + (qn - 3) // 2
else:
	er = 0
print(min([qi, qt, er, qe // 3]))


s = list(input())
comp = 'nineteen'
finish = False
count = 0
a = []
while finish == False:
	if count > 0:
		comp = 'ineteen'
	for i in comp:
		if i in s:
			a.append(i)
			s.remove(i)
		else:
			finish = True
			break
	else:
		count += 1
print(count)


a = input()
x = [a.count('i'), a.count('e') // 3, a.count('t')]
other = min(x)
n = a.count('n')
print(min(other, int((n - 1) / 2)))


a = input()
count = 0
x = list()
for i in a:
	x.append(i)
n = 0
it = 0
e = 0
t = 0
for i in x:
	if i == 'n':
		n = n + 1
	if i == 'i':
		it = it + 1
	if i == 'e':
		e = e + 1
	if i == 't':
		t = t + 1
n = (n - 1) // 2
if n > 0:
	e = e // 3
	count = min(n, e, it, t)
print(count)


N = 0
I = 0
E = 0
T = 0
for i in input():
	if i == 'n':
		N += 1
	elif i == 'i':
		I += 1
	elif i == 'e':
		E += 1
	elif i == 't':
		T += 1
min = int(E / 3)
if int(I / 1) < min:
	min = int(I / 1)
if int(T / 1) < min:
	min = int(T / 1)
if int(N - 1) / 2 < min:
	min = int((N - 1) / 2)
print(min)


a1 = input()
listas = [0, 0, 0, 0]
for i in a1:
	if i == 'n':
		listas[0] += 1
	elif i == 'e':
		listas[1] += 1
	elif i == 'i':
		listas[2] += 1
	elif i == 't':
		listas[3] += 1
a = True
w = False
final_answer = 0
while a == True:
	if listas[0] >= 5 and listas[1] >= 3 and (listas[2] >= 1) and (listas[3] >= 1):
		listas[0] -= 2
		listas[1] -= 3
		listas[2] -= 1
		listas[3] -= 1
		final_answer += 1
	elif listas[0] < 5 and listas[0] >= 3 and (listas[1] >= 3) and (listas[2] >= 1) and (listas[3] >= 1):
		listas[0] -= 3
		listas[1] -= 3
		listas[2] -= 1
		listas[3] -= 1
		final_answer += 1
	else:
		a = False
print(final_answer)


s = input()
letters = ['n', 'i', 'e', 't']
occ = [3, 1, 3, 1]
count = dict()
for letter in letters:
	count[letter] = 0
for letter in s:
	if letter in letters:
		count[letter] += 1
minocc = 42
for k in range(1, 4):
	letter = letters[k]
	c = count[letter] // occ[k]
	if c <= minocc:
		minocc = c
while minocc > 0 and count['n'] < 2 * minocc + 1:
	minocc -= 1
print(minocc)


entrada = str(input())
lista = list(entrada)
contn = 0
conti = 0
conte = 0
contt = 0
conttotal = 0
for a in lista:
	if a == 'n':
		contn = contn + 1
	if a == 'i':
		conti = conti + 1
	if a == 'e':
		conte = conte + 1
	if a == 't':
		contt = contt + 1
if contn - 3 >= 0 and conti - 1 >= 0 and (conte - 3 >= 0) and (contt - 1 >= 0):
	contn = contn - 3
	conti = conti - 1
	conte = conte - 3
	contt = contt - 1
	conttotal = conttotal + 1
else:
	print(conttotal)
	exit(0)
while contn - 2 >= 0 and conti - 1 >= 0 and (conte - 3 >= 0) and (contt - 1 >= 0):
	contn = contn - 2
	conti = conti - 1
	conte = conte - 3
	contt = contt - 1
	conttotal = conttotal + 1
print(conttotal)


A = 'niet'
B = [0] * 4
s = input()
for i in s:
	if i in A:
		B[A.index(i)] += 1
B[0] = (B[0] - 1) // 2
B[2] //= 3
print(0 if min(B) < 0 else min(B))


s = input()
n = -1
(c, e, t, i) = (0, 0, 0, 0)
for j in range(0, len(s)):
	if s[j] == 'n':
		n += 1
	if s[j] == 'i':
		i += 1
	if s[j] == 'e':
		e += 1
	if s[j] == 't':
		t += 1
	if n >= 2 and e >= 3 and (t >= 1) and (i >= 1):
		c += 1
		(n, e, t, i) = (n - 2, e - 3, t - 1, i - 1)
print(c)


from typing import Dict

def count_9teen(string: str) -> int:
	if len(string) < 8:
		return 0
	count = 0
	letter_count = init_9teen_counter()
	original_count = get_9teen_letter_count()
	for c in string:
		if c in letter_count:
			letter_count[c] = letter_count[c] + 1
	counts = [letter_count[c] // original_count[c] for c in 'iet']
	if letter_count['n'] >= 3:
		counts.append(1 + (letter_count['n'] - 3) // 2)
	else:
		counts.append(0)
	return min(counts)

def init_9teen_counter() -> Dict[chr, int]:
	letter_count = {}
	letter_count['i'] = 0
	letter_count['n'] = 0
	letter_count['e'] = 0
	letter_count['t'] = 0
	return letter_count

def get_9teen_letter_count() -> Dict[chr, int]:
	letter_count = {}
	letter_count['i'] = 1
	letter_count['n'] = 3
	letter_count['e'] = 3
	letter_count['t'] = 1
	return letter_count
string = input()
print(count_9teen(string))


s = input()
t = 'nineteen'
count = {}
match = 0
for i in t:
	count[i] = 0
for i in range(len(s)):
	if s[i] in count:
		match += 1
		count[s[i]] += 1
count['n'] -= 1
count['n'] //= 2
count['e'] //= 3
ans = int(min(count.values()))
print(max(0, ans))


s = input()
d = {}
for i in s:
	if i in d.keys():
		d[i] += 1
	else:
		d[i] = 1
if 'n' not in d.keys() or 'i' not in d.keys() or 'e' not in d.keys() or ('t' not in d.keys()):
	print(0)
else:
	x = min(d['i'], d['t'])
	y = min((d['n'] - 1) // 2, d['e'] // 3)
	print(min(x, y))


s = input()
x = s.count('n')
if x > 3:
	print(min(1 + (s.count('n') - 3) // 2, s.count('i'), s.count('e') // 3, s.count('t')))
else:
	print(min(s.count('n') // 3, s.count('i'), s.count('e') // 3, s.count('t')))


l = [c for c in input()]
count = 0
pops = [c for c in 'nineteen']
try:
	while True:
		for c in pops:
			l.remove(c)
		l.append('n')
		count += 1
except ValueError:
	print(count)


s = list(input())
qtd = 0
qtdN = s.count('n')
qtdT = s.count('t')
qtdI = s.count('i')
qtdE = s.count('e')
if qtdN > 3:
	qtdN = (qtdN - 3) // 2 + 1
else:
	qtdN = qtdN // 3
qtdE = qtdE // 3
print(min(qtdE, qtdI, qtdN, qtdT))


s = input()
s = [s[i:i + 1] for i in range(0, len(s), +1)]
if len(s) <= 100:
	n = (s.count('n') - 1) // 2
	i = s.count('i')
	t = s.count('t')
	e = s.count('e') // 3
	print(max(0, min(n, i, t, e)))


word = input()
possibyleNineteens = min([int((word.count('n') - 1) / 2), int(word.count('e') / 3), int(word.count('i') / 1), int(word.count('t') / 1)])
print(possibyleNineteens)


d = {'n': 0, 'i': 0, 'e': 0, 't': 0}
s = input()
for char in s:
	if char in ['n', 'i', 'e', 't']:
		d[char] += 1
print(max(0, min((d['n'] - 1) // 2, d['i'], d['e'] // 3, d['t'])))


import sys
_lines = sys.stdin.readlines()
input = iter(_lines).__next__

def main():
	s = input()
	L = [0] * 256
	for c in s:
		L[ord(c)] += 1
	m = 100
	m = min(m, int((L[ord('n')] - 1) / 2))
	m = min(m, L[ord('e')] // 3)
	m = min(m, L[ord('i')])
	m = min(m, L[ord('t')])
	print(m)
main()


s = input()
(n_n, n_i, n_e, n_t) = (0, 0, 0, 0)
for i in s:
	if i == 'n':
		n_n += 1
	elif i == 'i':
		n_i += 1
	elif i == 'e':
		n_e += 1
	elif i == 't':
		n_t += 1
n_n = int((n_n - 1) / 2)
n_e = int(n_e / 3)
print(min(n_n, n_e, n_t, n_i))


s = input()
l = list(s)
cul = list((0 for i in range(30)))
for el in l:
	cul[ord(el) - 97] += 1
if cul[ord('n') - 97] > 0:
	cul[ord('n') - 97] -= 1
print(min(cul[ord('n') - 97] // 2, min(cul[ord('e') - 97] // 3, min(cul[ord('t') - 97], cul[ord('i') - 97]))))


a = input()
count = {}
for x in a:
	if x not in count.keys():
		count[x] = 1
	else:
		count[x] += 1
c = 0
flag = False
if 'n' not in count.keys() or 't' not in count.keys() or 'i' not in count.keys() or ('e' not in count.keys()):
	flag = True
if flag == False:
	if count['n'] >= 3 and count['t'] >= 1 and (count['e'] >= 3) and (count['i'] >= 1):
		c = 1
		count['n'] -= 3
		count['t'] -= 1
		count['e'] -= 3
		count['i'] -= 1
	while c > 0 and count['n'] >= 2 and (count['t'] >= 1) and (count['e'] >= 3) and (count['i'] >= 1):
		count['n'] -= 2
		count['t'] -= 1
		count['e'] -= 3
		count['i'] -= 1
		c += 1
	print(c)
else:
	print(0)


s = str(input())
d = {'n': 0, 'i': 0, 'e': 0, 't': 0}
for i in s:
	if i in d:
		d[i] += 1
a = list(d.values())
(a[0], a[2]) = ((a[0] - 1) // 2, a[2] // 3)
print(max(0, min(a)))


import sys
nineteen = 'nineteen'
dic = {}

def get(cha):
	global dic
	if cha in dic:
		return dic[cha]
	else:
		return 0
line = input()
for cha in line:
	if cha in nineteen:
		dic[cha] = get(cha) + 1
if 'n' not in dic:
	print('0')
else:
	print(min((get('n') - 1) // 2, get('i'), get('e') // 3, get('t')))


string = str(input())
counter_n = 0
counter_i = 0
counter_e = 0
counter_t = 0
for i in range(len(string)):
	if string[i] == 'n':
		counter_n += 1
	elif string[i] == 'i':
		counter_i += 1
	elif string[i] == 'e':
		counter_e += 1
	elif string[i] == 't':
		counter_t += 1
if counter_n >= 3:
	counter_n = (counter_n - 3) // 2 + 1
else:
	counter_n = 0
counter = [counter_n, counter_i, counter_e // 3, counter_t]
print(min(counter))


count = int(0)
count2 = int(0)
count3 = int(0)
count4 = int(0)
low = int(0)
s = input()
size = len(s)
i = 0
for i in range(size):
	if s[i] == 'i':
		count = count + 1
	elif s[i] == 't':
		count2 = count2 + 1
	elif s[i] == 'n':
		count3 = count3 + 1
	elif s[i] == 'e':
		count4 = count4 + 1
low = int(count4 / 3)
if count < low:
	low = count
if count2 < low:
	low = count2
if (count3 - 1) / 2 < low:
	low = (count3 - 1) / 2
print(int(low))


characters = input()
number_of_n = 0
number_of_e = 0
number_of_i = 0
number_of_t = 0
counter = 0
for i in characters:
	if i == 'n':
		number_of_n += 1
		characters.replace(i, '')
	if i == 'e':
		number_of_e += 1
		characters.replace(i, '')
	if i == 'i':
		number_of_i += 1
		characters.replace(i, '')
	if i == 't':
		number_of_t += 1
		characters.replace(i, '')
	if number_of_t >= 1 and number_of_i >= 1 and (number_of_e >= 3) and (number_of_n >= 2):
		if counter >= 1:
			number_of_n -= 2
			number_of_e -= 3
			number_of_i -= 1
			number_of_t -= 1
			counter += 1
		if counter < 1 and number_of_n >= 3:
			number_of_n -= 3
			number_of_e -= 3
			number_of_i -= 1
			number_of_t -= 1
			counter += 1
print(counter)


string = input()
d = {}
d['n'] = d['i'] = d['e'] = d['t'] = 0
for i in string:
	if i in d:
		d[i] += 1
print(min(max(int((d['n'] - 1) / 2), 0), d['i'], int(d['e'] / 3), d['t']))


s = input()
(n, e, i, t) = (0, 0, 0, 0)
for c in s:
	if c == 'n':
		n += 1
	elif c == 'e':
		e += 1
	elif c == 'i':
		i += 1
	elif c == 't':
		t += 1
e //= 3
n = (n - 1) // 2
ans = min([e, n, i, t])
print(max(0, ans))


word = input()
count = {}
for char in word:
	count[char] = count.get(char, 0) + 1
lowest = len(word)
count2 = {}
count2['n'] = (count.get('n', 0) - 1) // 2
count2['e'] = count.get('e', 0) // 3
count2['i'] = count.get('i', 0)
count2['t'] = count.get('t', 0)
for char in 'niet':
	if count2[char] < lowest:
		lowest = count2[char]
print(lowest if lowest > 0 else 0)


from math import floor
s = input()
l = []
if s.count('n') % 2 == 0:
	l.append((s.count('n') - 1) // 2) if s.count('n') >= 3 else l.append(0)
else:
	l.append(s.count('n') // 2)
l.append(s.count('i'))
l.append(s.count('e') // 3)
l.append(s.count('t'))
print(min(l))


s = input()
i = n = t = e = 0
list = [i, n, t, e]
for v in s:
	if v == 'i':
		i += 1
	elif v == 'n':
		n += 1
	elif v == 't':
		t += 1
	elif v == 'e':
		e += 1
	else:
		pass
list[0] = i
if n == 0:
	list[1] = 0
elif n > 0:
	list[1] = (n - 1) // 2
list[2] = t
list[3] = e // 3
list.sort()
print(list[0])


string = input()
n = string.count('n')
i = string.count('i')
e = string.count('e')
t = string.count('t')
n -= 1
vn = n / 2
ve = e / 3
vi = i
vt = t
ans = max(0, min(vn, ve, vi, vt))
ans = int(ans)
print(ans)


s = input()
Ch = [i for i in s]
k = 0
for i in range(len(Ch)):
	if 'n' in Ch:
		x = Ch.index('n')
		Ch.pop(x)
		if 'i' in Ch:
			x = Ch.index('i')
			Ch.pop(x)
			if 'n' in Ch:
				x = Ch.index('n')
				Ch.pop(x)
				if 'e' in Ch:
					x = Ch.index('e')
					Ch.pop(x)
					if 't' in Ch:
						x = Ch.index('t')
						Ch.pop(x)
						if 'e' in Ch:
							x = Ch.index('e')
							Ch.pop(x)
							if 'e' in Ch:
								x = Ch.index('e')
								Ch.pop(x)
								if 'n' in Ch:
									x = Ch.index('n')
									k = k + 1
								else:
									break
							else:
								break
						else:
							break
					else:
						break
				else:
					break
			else:
				break
		else:
			break
print(k)


s = input()
ans = 0
n = i = e = t = 0
for j in range(len(s)):
	if s[j] == 'n':
		n += 1
	if s[j] == 'i':
		i += 1
	if s[j] == 'e':
		e += 1
	if s[j] == 't':
		t += 1
	j += 1
n = max(n - 1, 0) // 2
e = e // 3
ans = min(min(n, i), min(e, t))
print(ans)


a = input()
n = 0
i = 0
e = 0
t = 0
for j in a:
	if j == 'n':
		n += 1
	if j == 'i':
		i += 1
	if j == 'e':
		e += 1
	if j == 't':
		t += 1
if n > 3:
	n = (n - 3) // 2 + 1
else:
	n = n // 3
min = n
e = e // 3
if e < min:
	min = e
if i < min:
	min = i
if t < min:
	min = t
print(min)


temp = input()
n = temp.count('n')
if n % 2 == 0 and n > 5:
	n -= 1
if n > 4:
	n = n // 2
else:
	n //= 3
i = temp.count('i')
e = temp.count('e')
t = temp.count('t')
if i > 0 and e > 2 and (t > 0):
	max_words = min(n, e // 3, t, i)
	print(int(max_words))
else:
	print(0)


s = input()
nc = abs((s.count('n') - 1) // 2)
ic = s.count('i')
ec = s.count('e') // 3
tc = s.count('t')
print(min(ic, tc, ec, nc))


z = input()
x = [z.count('n'), z.count('i'), z.count('e'), z.count('t')]
x[0] = x[0] - 1
c = 0
while True:
	x[0] = x[0] - 2
	x[1] = x[1] - 1
	x[2] = x[2] - 3
	x[3] = x[3] - 1
	if x[0] < 0 or x[1] < 0 or x[2] < 0 or (x[3] < 0):
		break
	else:
		c = c + 1
print(c)


from collections import Counter
entrada = input()
nineteen = Counter('nineteen')
countEntrada = Counter(entrada)
resultado = float('inf')
for (letra, cant) in nineteen.items():
	if letra == 'n' and letra in countEntrada:
		multiplos = (countEntrada[letra] - 1) // (cant - 1)
	else:
		multiplos = countEntrada[letra] // cant
	if multiplos < resultado:
		resultado = multiplos
print(resultado)


def main():
	a = input().count
	print(min(max(0, (a('n') - 1) // 2), a('i'), a('e') // 3, a('t')))
main()


def main():
	s = input()
	ind1 = [3, 1, 3, 1]
	ind2 = [2, 1, 3, 1]
	acum = 0
	i = 0
	a = s.count('n')
	b = s.count('i')
	c = s.count('e')
	d = s.count('t')
	vet = [a, b, c, d]
	if vet[0] >= ind1[0] and vet[1] >= ind1[1] and (vet[2] >= ind1[2]) and (vet[3] >= ind1[3]):
		acum += 1
		vet[0] = vet[0] - ind1[0]
		vet[1] = vet[1] - ind1[1]
		vet[2] = vet[2] - ind1[2]
		vet[3] = vet[3] - ind1[3]
	else:
		print(acum)
		exit(0)
	while vet[0] >= ind2[0] and vet[1] >= ind2[1] and (vet[2] >= ind2[2]) and (vet[3] >= ind2[3]):
		acum += 1
		vet[0] = vet[0] - ind2[0]
		vet[1] = vet[1] - ind2[1]
		vet[2] = vet[2] - ind2[2]
		vet[3] = vet[3] - ind2[3]
	print(acum)
main()


def upd(a):
	x = v1[a]
	x = x + 1
	v1[a] = x
v = dict()
v.update({'n': 3})
v.update({'i': 1})
v.update({'e': 3})
v.update({'t': 1})
v1 = dict()
v1.update({'n': 0})
v1.update({'i': 0})
v1.update({'e': 0})
v1.update({'t': 0})
str = 'niet'
s = input()
for k in s:
	if k in str:
		upd(k)
min1 = 1000000
for i in v:
	if i != 'n':
		r = v1[i] // v[i]
		min1 = min(min1, r)
v1['n'] -= 3
nr = 1
rap = v1['n'] // 2
nr += rap
if nr > -1:
	min1 = min(min1, nr)
print(min1)


str = input()
n = str.count('n')
i = str.count('i')
e = str.count('e')
t = str.count('t')
ctr = 0
while True:
	if n >= 3 and i >= 1 and (e >= 3) and (t >= 1):
		ctr = ctr + 1
		n = n - 2
		i = i - 1
		e = e - 3
		t = t - 1
	else:
		break
print(ctr)


string_input = input()
char_count_dict = {}
count = 0
for char in string_input:
	char_count_dict[char] = char_count_dict.setdefault(char, 0) + 1
if 'n' not in char_count_dict or 'i' not in char_count_dict or 'e' not in char_count_dict or ('t' not in char_count_dict):
	possible = False
else:
	possible = True
while possible:
	if count == 0:
		if char_count_dict['n'] >= 3:
			char_count_dict['n'] = char_count_dict['n'] - 3
		else:
			break
	elif char_count_dict['n'] >= 2:
		char_count_dict['n'] = char_count_dict['n'] - 2
	else:
		break
	if char_count_dict['i'] >= 1 and char_count_dict['e'] >= 3 and (char_count_dict['t'] >= 1):
		count += 1
	else:
		break
	char_count_dict['i'] = char_count_dict['i'] - 1
	char_count_dict['t'] = char_count_dict['t'] - 1
	char_count_dict['e'] = char_count_dict['e'] - 3
print(count)


from collections import Counter
str = input()
count = Counter(str)
count['e'] //= 3
if count['n'] >= 3:
	count['n'] -= 3
	count['n'] //= 2
	count['n'] += 1
else:
	count['n'] = 0
mn = count['n']
base_str = 'nineteen'
for i in base_str:
	mn = min(mn, count[i])
print(mn)


from collections import Counter
s = input()
n = s.count('n')
i = s.count('i')
e = s.count('e')
t = s.count('t')
print(max(0, min((n - 1) // 2, i, e // 3, t)))


import sys
S = sys.stdin.readline()
S.rstrip('\n')
n = 0
i = 0
t = 0
e = 0
Slen = 0
for k in S:
	if k == 'n':
		n = n + 1
	elif k == 'i':
		i = i + 1
	elif k == 't':
		t = t + 1
	elif k == 'e':
		e = e + 1
	else:
		continue
	Slen = Slen + 1
maximo = 0
if Slen > 7:
	maximo = 1
	Slen = Slen - 8
	maximo = maximo + Slen // 7
Icheck = i
Tcheck = t
Echeck = e // 3
Ncheck = 0
if n > 2:
	Ncheck = 1
	n = n - 3
	Ncheck = Ncheck + n // 2
res = min(Ncheck, Icheck, Tcheck, Echeck, maximo)
print(res)


s = str(input())
a = s.count('n')
if a >= 3:
	h = 3
	count = 1
	while h != a:
		h = h + 2
		if h > a:
			break
		count = count + 1
else:
	count = 0
b = s.count('i') // 1
c = s.count('t') // 1
d = s.count('e') // 3
e = min(count, b)
f = min(c, d)
g = min(e, f)
print(g)


string = input()
n_num = 0
i_num = 0
e_num = 0
t_num = 0
for i in string:
	if i == 'n':
		n_num += 1
	elif i == 'i':
		i_num += 1
	elif i == 'e':
		e_num += 1
	elif i == 't':
		t_num += 1
print(min(int((n_num - 1) / 2), int(i_num), int(e_num / 3), int(t_num)))


s = input()
d = {'n': 0, 'i': 0, 'e': 0, 't': 0}
for i in s:
	if i in d:
		d[i] += 1
if d['n'] > 3:
	d['n'] -= 3
	d['n'] //= 2
	d['n'] += 1
else:
	d['n'] //= 3
d['i'] //= 1
d['e'] //= 3
d['t'] //= 1
print(min(d['n'], d['i'], d['e'], d['t']))


s = list(input())
fW = 'ineteen'
con = 1
n = 0
while con:
	conList = []
	for x in fW:
		if x in s:
			s.remove(x)
			conList.append(x)
		else:
			for y in conList:
				s.append(y)
			con = 0
			break
	else:
		n += 1
if s.count('n') < 1:
	if n > 1:
		n = n - 1
	else:
		n = 0
print(n)


text = input()

def solve(text):
	countN = 0
	countI = 0
	countE = 0
	countT = 0
	total = 0
	for x in text:
		if x == 'n':
			countN += 1
		elif x == 'i':
			countI += 1
		elif x == 'e':
			countE += 1
		elif x == 't':
			countT += 1
	while countN >= 3 and countI >= 1 and (countE >= 3) and (countT >= 1):
		total += 1
		countN -= 2
		countI -= 1
		countE -= 3
		countT -= 1
	return total
print(solve(text))


string = input()
count = []
count.append(max((string.count('n') - 1) // 2, 0))
count.append(string.count('i'))
count.append(string.count('e') // 3)
count.append(string.count('t'))
print(min(count))


import collections as cl
c = cl.Counter(input())
n_th = c['n'] // 3
print(min(c['i'], c['t'], max(0, c['n'] - 1) // 2, c['e'] // 3))


s = list(map(str, input().split()))
s = s[0]
n1 = int(s.count('n'))
n2 = int(s.count('e')) // 3
n3 = int(s.count('i'))
n4 = int(s.count('t'))
n = min(n2, n3, n4)
if n1 > 2:
	n1 = (n1 - 1) // 2
else:
	n1 = 0
print(min(n1, n))


s = input()
n = s.count('n')
n -= 1
n = n // 2
e = s.count('e')
e = e // 3
l = [n, s.count('i'), s.count('t'), e]
m = min(l)
if m == -1:
	print(0)
else:
	print(int(m))


from collections import Counter

def solve():
	text = input()
	WORD = 'nineteen'
	data = {'n': 0, 'i': 0, 'e': 0, 't': 0}
	data.update(filter(lambda item: item[0] in WORD, Counter(text).items()))
	required = Counter(WORD)
	result = -1
	can_take_word = True
	spare_n = -1
	while can_take_word:
		for key in required:
			data[key] -= required[key]
			if key == 'n':
				if data[key] < 0:
					if data[key] == -2:
						data[key] += 2 if spare_n >= 2 else spare_n
						spare_n -= 2
					elif data[key] == -1:
						data[key] += 1
				elif data[key] >= 0 and spare_n > 0:
					data[key] += spare_n
					spare_n = 0
				else:
					spare_n += 2
			if key == 'n' and data[key] + spare_n < 0 or data[key] < 0:
				can_take_word = False
				break
		result += 1
	print(result)
solve()


count = 0
s = input()
n_count = s.count('n')
i_count = s.count('i')
e_count = s.count('e')
t_count = s.count('t')
i = i_count // 1
e = e_count // 3
t = t_count // 1
n = (n_count - 1) // 2
min_val = min(i, e, t)
if min_val == 0:
	print(0)
else:
	print(min(n, min_val))


s = input()
test = True
som = 0
while test == True:
	try:
		s = list(s)
		s.pop(s.index('n'))
		s.pop(s.index('i'))
		s.pop(s.index('n'))
		s.pop(s.index('e'))
		s.pop(s.index('t'))
		s.pop(s.index('e'))
		s.pop(s.index('e'))
		s.pop(s.index('n'))
		som += 1
		s.append('n')
	except:
		test = False
print(som)


s = input()
n_cnt = s.count('n')
i_cnt = s.count('i')
e_cnt = s.count('e')
t_cnt = s.count('t')
if n_cnt >= 3:
	n_cnt = (n_cnt - 3) // 2 + 1
else:
	n_cnt //= 3
e_cnt //= 3
print(min(n_cnt, i_cnt, e_cnt, t_cnt))


J = str(input())
N = J.count('n')
I = J.count('i')
T = J.count('t')
E = J.count('e')
N = (N - 1) // 2
E = E // 3
if N > 0:
	M = min(N, I, T, E)
else:
	M = 0
print(M)


n = input()
k = n.count('i')
while k > 0:
	s = 0
	if n.count('n') >= 3 * k - k + 1:
		s += 1
	if n.count('e') >= 3 * k:
		s += 1
	if n.count('t') >= k:
		s += 1
	if s == 3:
		print(k)
		exit()
	k -= 1
print(k)


s = input()
koln = 0
koli = 0
kolt = 0
kole = 0
kolnn = 3
kolii = 1
koltt = 1
kolee = 3
kol = 1
for a in s:
	if a == 'n':
		koln += 1
	if a == 'i':
		koli += 1
	if a == 't':
		kolt += 1
	if a == 'e':
		kole += 1
c = 1
while koln >= kolnn and koli >= kolii and (kole >= kolee) and (kolt >= koltt):
	koln -= kolnn
	if c == 1:
		kolnn -= 1
		c = 0
	koli -= kolii
	kolt -= koltt
	kole -= kolee
	kol += 1
print(kol - 1)


a = [0, 0, 0]
p = 0
s = input()
for i in s:
	if i == 'n':
		p += 1
	elif i == 'i':
		a[0] += 1
	elif i == 'e':
		a[1] += 1
	elif i == 't':
		a[2] += 1
a[1] = a[1] / 3
n = min(a) // 1
if n == 0 or p == 0:
	print(0)
elif p >= 2 * n + 1:
	print(int(n))
elif p % 2 == 1:
	print(int((p - 1) / 2))
else:
	print(int((p - 2) / 2))


s = input()
(n_count, i_count, e_count, t_count) = (s.count('n'), s.count('i'), s.count('e'), s.count('t'))
cnt = e_count // 3
while cnt > 0:
	if i_count >= cnt and t_count >= cnt:
		if cnt == 1 and n_count >= 3 * cnt:
			break
		if cnt > 1 and n_count >= 2 * cnt + 1:
			break
		else:
			cnt -= 1
	else:
		cnt -= 1
print(cnt)


letters = ['n', 'i', 't', 'e']
s = input()
lenth = len(s)
num = [0, 0, 0, 0]
for i in range(lenth):
	if s[i] in letters:
		if s[i] == 'n':
			num[0] = num[0] + 1
		elif s[i] == 'i':
			num[1] = num[1] + 1
		elif s[i] == 't':
			num[2] = num[2] + 1
		elif s[i] == 'e':
			num[3] = num[3] + 1
minEnc = int(min(num[1], num[2], num[3] // 3))
if minEnc == 0:
	print(0)
elif minEnc * 2 + 1 <= num[0]:
	print(minEnc)
else:
	while minEnc * 2 + 1 > num[0]:
		minEnc = minEnc - 1
	print(minEnc)


def sjs():
	str1 = input()
	n = 0
	resoult = {}
	for i in str1:
		resoult[i] = str1.count(i)
	try:
		for i in range(resoult['i']):
			if n == 0:
				if resoult['n'] >= 3 and resoult['i'] >= 1 and (resoult['e'] >= 3) and (resoult['t'] >= 1):
					resoult['n'] = resoult['n'] - 3
					resoult['i'] = resoult['i'] - 1
					resoult['e'] = resoult['e'] - 3
					resoult['t'] = resoult['t'] - 1
					n = n + 1
				else:
					break
			elif resoult['n'] >= 2 and resoult['i'] >= 1 and (resoult['e'] >= 3) and (resoult['t'] >= 1):
				resoult['n'] = resoult['n'] - 2
				resoult['i'] = resoult['i'] - 1
				resoult['e'] = resoult['e'] - 3
				resoult['t'] = resoult['t'] - 1
				n = n + 1
			else:
				break
		print(n)
	except:
		print(0)
sjs()


def main():
	_input = input()
	cnt_n = max(0, (_input.count('n') - 1) // 2)
	cnt_i = _input.count('i')
	cnt_e = _input.count('e') // 3
	cnt_t = _input.count('t')
	print(min(cnt_n, cnt_i, cnt_e, cnt_t))
main()


import collections
word = input().strip()
letters = collections.Counter(word)
n = letters.get('n') or 0
if n < 5:
	print(min([letters['n'] // 3, letters['i'], letters['e'] // 3, letters['t']]))
else:
	print(min([(letters['n'] - 1) // 2, letters['i'], letters['e'] // 3, letters['t']]))


str = input()
nc = str.count('n')
ic = str.count('i')
tc = str.count('t')
ec = str.count('e')
print(max(0, min((nc - 1) // 2, ec // 3, ic, tc)))


from collections import Counter
inp = input()
freq = Counter(inp)
print(min([max((freq['n'] - 3) // 2 + 1, 0), freq['t'], freq['i'], freq['e'] // 3]))


st = input()
n = (st.count('n') - 1) / 2
i = st.count('i')
e = st.count('e') / 3
t = st.count('t')
print(int(min(n, i, e, t)))


word = input()
nCount = 0
iCount = 0
eCount = 0
tCount = 0
for i in word:
	if i == 'n':
		nCount += 1
	elif i == 'i':
		iCount += 1
	elif i == 'e':
		eCount += 1
	elif i == 't':
		tCount += 1
if nCount >= 3:
	nCount -= 1
	print(min(nCount // 2, eCount // 3, tCount, iCount))
else:
	nCount = 0
	print(min(nCount // 2, eCount // 3, tCount, iCount))


s = input()
a = 0
b = 0
c = 0
d = 0
for i in s:
	if i == 'e':
		a = a + 1
	elif i == 'n':
		b = b + 1
	elif i == 'i':
		c = c + 1
	elif i == 't':
		d = d + 1
a = a // 3
k = min(a, c, d)
if b >= 2 * k + 1:
	if b == 1:
		print(b - 1)
	else:
		print(k)
elif b % 2 == 1:
	b = (b - 1) // 2
	k = min(k, b)
	print(k)
else:
	if b > 0:
		b = b // 2 - 1
	k = min(k, b)
	print(k)


t = {i: 0 for i in 'qwertyuiopasdfghjklzxcvbnm'}
for i in input():
	t[i] += 1
print(min([t['i'], t['t'], t['e'] // 3, max(0, t['n'] - 1) // 2]))


s = list(input())
n = s.count('n')
i = s.count('i')
e = s.count('e')
t = s.count('t')
c = 0
while 1:
	if i >= 1 and e >= 3 and (t >= 1):
		i = i - 1
		e = e - 3
		t = t - 1
		c = c + 1
	else:
		break
if c == 0:
	print(0)
elif n >= 2 * c + 1:
	print(c)
else:
	while n < 2 * c + 1:
		c = c - 1
	print(c)


a = input()
i_s = a.count('i')
n_s = (a.count('n') - 1) // 2
e_s = a.count('e') // 3
t_s = a.count('t')
if n_s < 0:
	print(0)
else:
	print(min(i_s, n_s, e_s, t_s))


import math
s = str(input())
ans = 0
n = 0
i = 0
e = 0
t = 0
for k in s:
	if k == 'n':
		n += 1
	elif k == 'i':
		i += 1
	elif k == 'e':
		e += 1
	elif k == 't':
		t += 1
n = int((n - 1) / 2)
e = int(e / 3)
ans = min(n, i, e, t)
print(ans)


import math
s = 'nineteenineteenineteenineteenineteenineteenineteenineteenineteenineteenineteenineteenineteen'
s = input().strip()
s_len = len(s)
s_occ = {'i': 1, 'e': 3, 't': 1, 'n': 3}
min_occ = s_len
for c in s_occ:
	cnt = s.count(c)
	if c == 'n' and cnt > 3:
		cnt_inc = int(cnt / 3)
		cnt += cnt_inc + int(cnt_inc / 3)
	occ = int(cnt / s_occ[c])
	if occ < min_occ:
		min_occ = occ
print(min_occ)


l = [0] * 26
s = input()
for i in s:
	l[ord(i) - 97] += 1
n = (l[13] - 1) / 2
i = l[8]
e = l[4] / 3
t = l[19]
print(int(min(n, i, t, e)))


s = input()
(n, i, e, t) = (0, 0, 0, 0)
for c in s:
	if c == 'n':
		n += 1
	elif c == 'i':
		i += 1
	elif c == 'e':
		e += 1
	elif c == 't':
		t += 1
if n >= 3:
	n -= 3
	n = int(n / 2) + 1
else:
	n = 0
e = int(e / 3)
print(min(n, i, e, t))


from collections import Counter
STRING = 'nineteen'
MCOUNTER = Counter(STRING)
MSET = set('iet')

def function(inp):
	inpc = Counter(inp)
	inps = set(inpc)
	if inps & MSET == MSET and 'n' in inpc:
		m = 10000
		for c in MSET:
			m = min(inpc[c] // MCOUNTER[c], m)
		if m == 0 or inpc['n'] < 3:
			return 0
		else:
			m2 = (inpc['n'] - 3) // 2 + 1
			return min(m, m2)
	else:
		return 0

def main():
	inp = input()
	out = function(inp)
	print(out)
main()


x = input()
arr = []
n = x.count('n')
e = x.count('e')
t = x.count('t')
i = x.count('i')
arr.append(int((n - 1) / 2))
arr.append(i)
arr.append(int(e / 3))
arr.append(t)
print(min(arr))


a = input()
e = a.count('e')
n = a.count('n')
i = a.count('i')
t = a.count('t')
counter = 0
while True:
	if e < 3 or i < 1 or t < 1:
		break
	if counter:
		if n < 2:
			break
		n -= 2
	else:
		if n < 3:
			break
		n -= 3
	counter += 1
	e -= 3
	i -= 1
	t -= 1
print(counter)


s = str(input())
CountN = 0
CountI = 0
CountE = 0
CountT = 0
for word in s:
	if word == 'n':
		CountN += 1
	elif word == 'i':
		CountI += 1
	elif word == 'e':
		CountE += 1
	elif word == 't':
		CountT += 1
if CountN < 3 or CountE < 3 or CountT < 1 or (CountI < 1):
	print(0)
else:
	print(min((CountN - 1) // 2, CountE // 3, CountT, CountI))


s = input()
temp = 'ineteen'
temp1 = 'nineteen'
d2 = {}
l = []
d = {}
for i in s:
	if i in d:
		d[i] += 1
	else:
		d[i] = 1
if 'n' in d and d['n'] > 3:
	d['n'] -= 1
	for i in temp:
		if i in d2:
			d2[i] += 1
		else:
			d2[i] = 1
else:
	for i in temp1:
		if i in d2:
			d2[i] += 1
		else:
			d2[i] = 1
l = [d[i] // d2[i] if i in d else 0 for i in d2]
print(min(l))


s = input()
n = s.count('n')
i = s.count('i')
e = s.count('e')
t = s.count('t')
if n >= 5:
	num = min(int(e / 3), int(i), int(t), int((n - 1) / 2))
else:
	num = min(int(e / 3), int(i), int(t), int(n / 3))
print(num)


x = list(input())
print(int(min((x.count('n') - 1) / 2, x.count('i'), x.count('e') / 3, x.count('t'))))


x = input()
n = x.count('n')
e = x.count('e')
i = x.count('i')
t = x.count('t')
n1 = (n - 1) // 2
e1 = e // 3
lim = min(n1, e1, i, t)
if lim > 0:
	print(lim)
else:
	print(0)


word = list(input())
check = ['n', 'i', 'e', 't']
word_dict = {'n': 0, 'i': 0, 'e': 0, 't': 0}
count = 0
for i in range(len(word)):
	if word[i] in check:
		word_dict[word[i]] = word_dict[word[i]] + 1
	if word_dict['n'] >= 3 and word_dict['i'] >= 1 and (word_dict['e'] >= 3) and (word_dict['t'] >= 1):
		count = count + 1
		word_dict['n'] = word_dict['n'] - 2
		word_dict['i'] = word_dict['i'] - 1
		word_dict['e'] = word_dict['e'] - 3
		word_dict['t'] = word_dict['t'] - 1
print(count)


import math
s = input()
count_n = -1
count_i = 0
count_e = 0
count_t = 0
for char in s:
	if char == 'n':
		count_n += 1
	elif char == 'i':
		count_i += 1
	elif char == 'e':
		count_e += 1
	elif char == 't':
		count_t += 1
print(min(int(count_n / 2), int(count_i), int(count_e / 3), int(count_t)))


import sys
s = input()
if s == '':
	print(0)
	sys.exit()
freq = {'n': 0, 'i': 0, 'e': 0, 't': 0}
for i in s:
	if i == 'n' or i == 'i' or i == 'e' or (i == 't'):
		freq[i] += 1
m = 999999999
for i in freq:
	if i == 'e':
		m = min(m, freq[i] // 3)
	else:
		m = min(m, freq[i])
m = min((freq['n'] - 1) // 2, m)
if m < 0:
	m = 0
print(m)


s = input()
n = 0
i = 0
e = 0
t = 0
for j in range(len(s)):
	if s[j] == 'n':
		n += 1
	elif s[j] == 't':
		t += 1
	elif s[j] == 'i':
		i += 1
	elif s[j] == 'e':
		e += 1
if n == 0:
	print(0)
else:
	print(min(min(t, i), min((n - 1) // 2, e // 3)))


s = input()
vl = {'n': -1, 'i': 0, 'e': 0, 't': 0}
for i in s:
	if i in vl:
		vl[i] += 1
vl['e'] /= 3
vl['n'] /= 2
m = 100000
for i in vl.values():
	m = min(m, i)
print(int(m))


string = input()
n = string.count('n')
i = string.count('i')
e = string.count('e')
t = string.count('t')
if n >= 3:
	n = n - 3
	n = n // 2
	n += 1
else:
	n = 0
lista = []
lista.append(n)
lista.append(i)
lista.append(e // 3)
lista.append(t)
lista.sort()
print(lista[0])


st = input()
a = st.count('n')
b = st.count('e')
c = st.count('t')
d = st.count('i')
e = [(a - 1) // 2, b // 3, c, d]
if min(e) < 0:
	print(0)
else:
	print(min(e))


import sys
all_input = ''.join(sys.stdin.readlines()).strip()
freq = {c: 0 for c in 'niet'}
for c in all_input:
	if c not in freq:
		freq[c] = 0
	freq[c] += 1
sol = min([(freq['n'] - 1) // 2, freq['i'], freq['e'] // 3, freq['t']])
print(sol if sol > 0 else 0)


s = input()
c = lambda a: s.count(a)
ans = max(0, min((c('n') - 1) // 2, c('i'), c('e') // 3, c('t')))
print(ans)


a = str(input())
import collections
cnt = collections.Counter(a)
ans = min({(cnt['n'] - 1) // 2, cnt['e'] // 3, cnt['i'], cnt['t']})
if ans < 1:
	print(0)
else:
	print(ans)


def main():
	S = input()
	D = {'n': 0, 'i': 0, 'e': 0, 't': 0}
	for c in S:
		if c in D:
			D[c] += 1
	D['n'] -= 1
	D['n'] /= 2
	D['e'] /= 3
	print(int(min(D['n'], D['i'], D['e'], D['t'])))
main()


def test(inp, ans):
	myans = fun1(inp)
	passed = ans == myans
	print(f'inp: {inp}, ans: {ans}, myans: {myans}\npassed: {passed}')

def fun1(inp):
	word = 'nineteen'
	allowed_letters = set(list(word))
	counter = 0
	detected_chars = {'n': 0, 'i': 0, 't': 0, 'e': 0}
	for (i, char) in enumerate(inp):
		if char in allowed_letters:
			detected_chars[char] += 1
	detected_chars['e'] //= 3
	ncount = 1 if detected_chars['n'] - 3 >= 0 else 0
	detected_chars['n'] = (detected_chars['n'] - 3) * ncount // 2 + ncount
	min_count = min(detected_chars.values())
	return min_count

def sol():
	inp = input()
	print(fun1(inp))
sol()


(n, i, e, t) = (0, 0, 0, 0)
ans = 0
for j in input():
	if j == 'n':
		n = n + 1
	if j == 'e':
		e = e + 1
	if j == 'i':
		i = i + 1
	if j == 't':
		t = t + 1
if n > 0:
	ans = min((n - 1) // 2, e // 3, i, t)
print(ans)


a = list(input())
e = a.count('e')
i = a.count('i')
t = a.count('t')
n = a.count('n')
total1 = 0
total2 = 0
while i >= 1 and e >= 3 and (t >= 1):
	i -= 1
	e -= 3
	t -= 1
	total1 += 1
if n >= 3:
	n -= 3
	total2 += 1
	while n >= 2:
		n -= 2
		total2 += 1
print(min(total1, total2))


s = input()
nineteen = 'nineteen'
times = 0
counts = {'n': 0, 'i': 0, 'e': 0, 't': 0}
found_one = False
for char in s:
	if char in nineteen:
		counts[char] += 1
	if found_one and counts['n'] >= 2 and (counts['i'] >= 1) and (counts['e'] >= 3) and (counts['t'] >= 1):
		times += 1
		found_one = True
		counts['n'] -= 2
		counts['i'] -= 1
		counts['e'] -= 3
		counts['t'] -= 1
	elif counts['n'] >= 3 and counts['i'] >= 1 and (counts['e'] >= 3) and (counts['t'] >= 1):
		times += 1
		found_one = True
		counts['n'] -= 3
		counts['i'] -= 1
		counts['e'] -= 3
		counts['t'] -= 1
print(times)


import math
s = input()
(n, i, t, e) = [0] * 4
for char in s:
	if char == 'n':
		n += 1
	elif char == 'i':
		i += 1
	elif char == 't':
		t += 1
	elif char == 'e':
		e += 1
counts = [(n - 1) // 2 if n > 0 else 0, i, t, e // 3]
print(min(counts))


string = input()
letters = {}
for letter in string:
	if letter in letters:
		letters[letter] += 1
	else:
		letters[letter] = 1
if any([letter not in letters for letter in 'nite']):
	print(0)
else:
	number = float('inf')
	for letter in 'iten':
		if letter == 'i':
			number = min(letters[letter], number)
		elif letter == 't':
			number = min(letters[letter], number)
		elif letter == 'e':
			number = min(letters[letter] // 3, number)
		elif letters[letter] < 3:
			number = 0
		else:
			number = min((letters[letter] - 3) // 2 + 1, number)
	print(number)


s = input()
cn = ci = ce = ct = 0
for i in s:
	if i == 'n':
		cn += 1
	elif i == 'i':
		ci += 1
	elif i == 'e':
		ce += 1
	elif i == 't':
		ct += 1
n = min((cn - 1) // 2, ci, ce // 3, ct)
print((n, 0)[0 > n])


from collections import Counter
import math
s = input()
cnt = Counter(s)
cnt['e'] = cnt['e'] // 3
t = 'n' * cnt['n']
res = 0
while len(t) >= 3:
	res += 1
	t = t[2:]
cnt['n'] = res
res = min(cnt['n'], cnt['i'], cnt['t'], cnt['e']) if min(cnt['n'], cnt['i'], cnt['t'], cnt['e']) >= 0 else 0
print(res)


def Nineteen(string):
	n = string.count('n')
	i = string.count('i')
	e = string.count('e')
	t = string.count('t')
	temp = 0
	while not (n - 1 < 2 or i < 1 or e < 3 or (t < 1)):
		temp += 1
		n -= 2
		i -= 1
		e -= 3
		t -= 1
	return temp
print(Nineteen(input()))


s = input().strip()
n = s.count('n')
e = s.count('e') // 3
i = s.count('i')
t = s.count('t')
count = min(e, i, t)
for i in range(count, -1, -1):
	if 2 * i + 1 <= n:
		print(i)
		break
	elif 3 * i <= n:
		print(i)
		break


import sys
s = input().strip()
inpDict = {}
for c in s:
	inpDict[c] = inpDict.get(c, 0) + 1
nn = 'nineteen'
nDict = {}
for c in nn:
	nDict[c] = nDict.get(c, 0) + 1
m = sys.maxsize
for c in nDict.keys():
	if c != 'n':
		m = min(m, inpDict.get(c, 0) // nDict[c])
if (inpDict.get('n', 0) - 1) // 2 >= m:
	if m >= 0:
		print(m)
	else:
		print(0)
else:
	x = (inpDict.get('n', 0) - 1) // 2
	if x >= 0:
		print(x)
	else:
		print(0)


def remch(ch, string):
	ss = list(string)
	ss.remove(ch)
	return ss

def fun(string):
	s = string[:]
	nums = 0
	stand = 'nineteen'
	while True:
		n = len(s)
		ind = []
		for i in range(len(s)):
			if s[i] in stand:
				ind.append(i)
				stand = remch(s[i], stand)
			if stand == []:
				nums = nums + 1
				break
		if ind == []:
			break
		chd = [s[i] for i in ind]
		for cd in chd:
			s = remch(cd, s)
		stand = 'ineteen'
	return nums
print(fun(input()))


n = input()
l = list(n)
t = ['n', 'i', 'n', 'e', 't', 'e', 'e', 'n']
temp = 0
count = {}
for i in l:
	n = l.count(i)
	count[i] = n
i = 1
temp = 0
while i == 1:
	temp += 1
	for j in t:
		if j in count.keys():
			if count[j] == 0:
				temp -= 1
				i = 0
				break
			else:
				count[j] -= 1
		else:
			temp -= 1
			i = 0
			break
	if 'n' in count.keys():
		count['n'] += 1
print(temp)


word = 'nineteen'
count_char = {'e': 3, 'i': 1, 't': 1, 'n': 3}
input_string = str(input())
count_input_char = dict()
for char in input_string:
	if char in count_input_char:
		count_input_char[char] += 1
	else:
		count_input_char[char] = 1
ans = 0
check = False
while True:
	for (char, amount) in count_char.items():
		if char in count_input_char:
			if count_input_char[char] - amount < 0:
				check = True
				break
			else:
				count_input_char[char] -= amount
		else:
			check = True
			break
	if check:
		break
	ans += 1
	if ans == 1:
		count_char['n'] -= 1
print(ans)


palabra = input()
ce = 0
ci = 0
cn = 0
ct = 0
for i in palabra:
	if 'e' == i:
		ce += 1
	elif 'n' == i:
		cn += 1
	elif 't' == i:
		ct += 1
	elif 'i' == i:
		ci += 1
total = 0 if 3 > cn else 1 + (cn - 3) / 2
cont = min(total, ct, ci, ce / 3)
print(int(cont))


s = input()
niet = 'niet'
dict = {}
for letra in s:
	if letra in niet:
		dict[letra] = dict.get(letra, 0) + 1
for letra in niet:
	if letra == 'e':
		aux = 3
	elif letra == 'i' or letra == 't':
		aux = 1
	elif letra == 'n':
		aux = 2
	if letra == 'n':
		dict[letra] = (dict.get(letra, 0) - 1) // aux
	else:
		dict[letra] = dict.get(letra, 0) // aux
min = min(dict.values())
if min >= 0:
	print(min)
else:
	print(0)


s = input()
needs = [2, 1, 3, 1]
counts = [0, 0, 0, 0]
for i in range(0, len(s)):
	if s[i] == 'n':
		counts[0] += 1
	if s[i] == 'i':
		counts[1] += 1
	if s[i] == 'e':
		counts[2] += 1
	if s[i] == 't':
		counts[3] += 1
counts[0] -= 1
for i in range(0, 4):
	counts[i] = counts[i] // needs[i]
ans = max(min(counts), 0)
print(ans)


from collections import Counter
s = input()
a = Counter('nineteen')
c = Counter(s)
set_ = {'n', 'i', 'e', 't'}
ans = 100
for el in set_:
	if el != 'n':
		ans = min(ans, s.count(el) // a[el])
	else:
		ans = min(ans, max(0, (s.count('n') - 1) // 2))
print(ans)


r = input()
n = -1
(c, e, t, u) = (0, 0, 0, 0)
for i in r:
	if i == 'n':
		n += 1
	if i == 'e':
		e += 1
	if i == 't':
		t += 1
	if i == 'i':
		u += 1
	if n >= 2 and e >= 3 and (t >= 1) and (u >= 1):
		c += 1
		(n, e, t, u) = (n - 2, e - 3, t - 1, u - 1)
print(c)


s = input()
v1 = 0
v2 = 0
v3 = 0
v4 = 0
val = 0
for x in range(0, len(s)):
	if s[x] == 'n':
		v1 = v1 + 1
	elif s[x] == 'i':
		v2 = v2 + 1
	elif s[x] == 'e':
		v3 = v3 + 1
	elif s[x] == 't':
		v4 = v4 + 1
v1 = (v1 - 1) // 2
v3 = v3 // 3
while v1 != 0 and v3 != 0 and (v2 != 0) and (v4 != 0):
	val = val + 1
	v1 = v1 - 1
	v2 = v2 - 1
	v3 = v3 - 1
	v4 = v4 - 1
print(val)


import math
s = input()
n_count = s.count('n')
e_count = s.count('e')
n = math.floor((n_count - 1) / 2)
e = math.floor(e_count / 3)
i = s.count('i')
t = s.count('t')
print(max(min(n, i, t, e), 0))


str = input()
counts = {'n': 0, 'i': 0, 'e': 0, 't': 0}
for c in str:
	if c in 'niet':
		counts[c] += 1
ans = len(str)
for (c, v) in counts.items():
	if c == 'n':
		if not v % 2:
			v -= 1
		v = int(v / 2)
	elif c == 'e':
		v = int(v / 3)
	ans = min(ans, v)
print(ans)


s = input()
d = {}
ab = 'abcdefghijklmnopqrstuvwxyz'
for j in ab:
	d[j] = 0
for j in s:
	if j in d:
		d[j] += 1
	else:
		d[j] = 1
c = 0
fl = 0
if d['n'] >= 3 and d['i'] >= 1 and (d['e'] >= 3) and (d['t'] >= 1):
	c = c + 1
	fl = 0
	d['n'] -= 3
	d['e'] -= 3
	d['i'] -= 1
	d['t'] -= 1
else:
	fl = 1
while 1:
	if fl == 1:
		break
	if d['i'] >= 1 and d['n'] >= 2 and (d['e'] >= 3) and (d['t'] >= 1):
		d['n'] -= 2
		d['i'] -= 1
		d['t'] -= 1
		d['e'] -= 3
		c += 1
	else:
		fl = 1
print(c)


a = input()
w = 'niet'
flag = 0
d = []
for item in w:
	if item not in a:
		flag = 1
		break
for item in a:
	d.append(item)
if flag == 1:
	print(0)
else:
	from collections import Counter
	c = Counter(d)
	b = [c['e'] // 3, c['i'], c['t']]
	k = min(b)
	if c['n'] >= 2 * k + 1:
		print(k)
	elif c['n'] <= 2:
		print('0')
	else:
		print(1 + (c['n'] - 3) // 2)


s = input()
count_n = 0
count_i = 0
count_e = 0
count_t = 0
for i in s:
	if i == 'n':
		count_n += 1
	elif i == 'i':
		count_i += 1
	elif i == 'e':
		count_e += 1
	elif i == 't':
		count_t += 1
	else:
		pass
if 3 <= count_n < 5:
	n = 1
elif count_n < 3:
	n = 0
else:
	n = (count_n - 5) // 2 + 2
print(min(count_e // 3, count_i, n, count_t))


str = input()
ans = {'n': 0, 'i': 0, 'e': 0, 't': 0}
for i in str:
	if i in ans:
		ans[i] += 1
ans['n'] -= 1
ans['n'] //= 2
ans['e'] //= 3
ans = min(ans.values())
print(ans if ans > 0 else 0)


a = str(input())
n = a.count('n')
i = a.count('i')
e = a.count('e')
t = a.count('t')
n = n - 3
extra = 1
n = n // 2 + extra
i = i
e = e // 3
t = t
if min(n, i, e, t) < 0:
	ans = 0
else:
	ans = min(n, i, e, t)
print(ans)


d = {'n': 0, 'i': 0, 'e': 0, 't': 0}
for e in input():
	if e in 'niet':
		d[e] += 1
print(max(0, min((d['n'] - (d['n'] % 2 == 0)) // 2, d['i'], d['e'] // 3, d['t'])))


string = input()
letters_count = {'n': 0, 'i': 0, 'e': 0, 't': 0}
for char in string:
	if char in letters_count.keys():
		letters_count[char] += 1
count = 0
if letters_count['n'] >= 3 and letters_count['i'] >= 1 and (letters_count['e'] >= 3) and (letters_count['t'] >= 1):
	count += 1
	letters_count['n'] -= 3
	letters_count['e'] -= 3
	letters_count['i'] -= 1
	letters_count['t'] -= 1
if count > 0:
	while letters_count['n'] >= 2 and letters_count['i'] >= 1 and (letters_count['e'] >= 3) and (letters_count['t'] >= 1):
		count += 1
		letters_count['n'] -= 2
		letters_count['e'] -= 3
		letters_count['i'] -= 1
		letters_count['t'] -= 1
print(count)


s = input()
n = e = t = i = 0
n = s.count('n')
e = s.count('e')
i = s.count('i')
t = s.count('t')
if t == 0 or i == 0 or e < 3 or (n < 3):
	w = 0
else:
	w = min(e // 3, t, i)
	while n < w * 3 - (w - 1):
		w -= 1
print(w)


x = input()
a = []
for i in x:
	a.append(i)
b = a.count('n')
c = a.count('i')
d = int(a.count('e') // 3)
e = a.count('t')
p = min(c, d, e)
j = 1
r = 0
while j <= p:
	k = 2 * j + 1
	if b >= k:
		r += 1
	else:
		break
	j += 1
print(r)


import fileinput
for line in fileinput.input():
	x = line
countn = 0
counti = 0
counte = 0
countt = 0
for i in range(len(x)):
	if x[i] == 'n':
		countn += 1
	if x[i] == 'i':
		counti += 1
	if x[i] == 'e':
		counte += 1
	if x[i] == 't':
		countt += 1
countn -= 3
counti -= 1
counte -= 3
countt -= 1
total = 0
if countn >= 0 and counti >= 0 and (counte >= 0) and (countt >= 0):
	total += 1
while countn - 2 >= 0 and counti - 1 >= 0 and (counte - 3 >= 0) and (countt - 1 >= 0):
	countn -= 2
	counti -= 1
	counte -= 3
	countt -= 1
	total += 1
print(total)


c = [0] * (ord('z') + 1)
for i in input():
	t = ord(i)
	c[t] += 1
o = max(0, (c[ord('n')] - 1) // 2)
o = min(o, c[ord('i')], c[ord('t')], c[ord('e')] // 3)
print(o)


n = input()
a = []
b = []
count = 0
b = n.lower()
for i in b:
	if i == 'n' or i == 'i' or i == 'e' or (i == 't'):
		a.append(i)
c = a
for i in range(len(c) // 7):
	if a.count('n') >= 3 and a.count('i') >= 1 and (a.count('t') >= 1) and (a.count('e') >= 3):
		count += 1
		del a[a.index('n')]
		del a[a.index('n')]
		del a[a.index('i')]
		del a[a.index('t')]
		del a[a.index('e')]
		del a[a.index('e')]
		del a[a.index('e')]
	else:
		break
print(count)


s = input()
f = [0] * 200
for i in range(0, len(s)):
	x = ord(s[i])
	f[x] += 1
mini = 100000000
x = [ord('i'), ord('n'), ord('t'), ord('e')]
for i in x:
	if i == ord('n'):
		mini = min(mini, int((f[i] - 1) / 2))
	elif i == ord('e'):
		mini = min(mini, f[i] // 3)
	else:
		mini = min(mini, f[i])
print(mini)


str = list(input())
nineteen = {'n': 3, 'i': 1, 'e': 3, 't': 1}
str_count = [str.count(key) // value for (key, value) in nineteen.items()]
str_count[0] = (str.count('n') - 3) // 2 + 1
output = max(min(str_count), 0)
print(output)


string = str(input())
occurrences = []
n_N = int(string.count('n'))
n_I = int(string.count('i'))
n_E = int(string.count('e'))
n_T = int(string.count('t'))
words = min([n_I, n_T, int(n_E / 3)])
if 3 + (words - 1) * 2 > n_N:
	words = 1 + (n_N - 3) / 2
print(int(words))


word = input()
n = i = t = e = 0
if len(word) <= 100:
	for j in word:
		if j == 'n':
			n += 1
		if j == 'i':
			i += 1
		if j == 't':
			t += 1
		if j == 'e':
			e += 1
	ans = i
	ans = min(ans, t)
	tmp = int((n - 1) / 2)
	ans = min(ans, tmp)
	del tmp
	tmp = int(e / 3)
	ans = min(ans, tmp)
	print(ans)


s = input()
ans = s.count('i')
ans = min(ans, s.count('t'))
ans = min(ans, (s.count('n') - 1) / 2)
ans = min(ans, s.count('e') / 3)
print(int(ans))


s = input()
chars = {'n': 1, 'i': 1, 'e': 3, 't': 1}
l = []
for char in chars:
	l.append(int(s.count(char) / chars[char]))
ans = min(l[1:])
print(min(ans, int((l[0] - 1) / 2)))


st = input()
a = {'n': 0, 'i': 0, 'e': 0, 't': 0}
for c in st:
	if c in a:
		a[c] += 1
print(max(min([(a['n'] - 1) // 2, a['i'], a['e'] // 3, a['t']]), 0))


hash = {}
list = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
for i in list:
	hash[i] = 0
t = input()
for i in t:
	hash[i] += 1
ans = 0
if hash['n'] < 5:
	ans1 = hash['n'] // 3
elif (hash['n'] - 5) % 2 == 0:
	ans1 = hash['n'] // 2
else:
	ans1 = (hash['n'] - 1) // 2
ans2 = hash['t']
ans3 = hash['i']
ans4 = hash['e'] // 3
print(min(ans1, ans2, ans3, ans4))


x = input()
i = x.count('i')
e = x.count('e') // 3
t = x.count('t')
n = x.count('n')
u = n - 3
k = 1
if e > 0:
	k += u // 2
rez = min(i, e, t, k)
print(rez)


def main(s):
	from collections import Counter
	count = Counter(s)
	n = {'n': 2, 'i': 1, 'e': 3, 't': 1}
	f = True
	x = ''
	for i in range(len(s)):
		for c in n:
			if count[c] < n[c]:
				f = False
				break
		if not f:
			break
		for c in n:
			count[c] -= n[c]
		x += 'ninetee'
	if count['n'] > 0:
		x += 'n'
	r = 0
	for i in range(0, len(x) + 2, 7):
		if x[i:i + 8] == 'nineteen':
			r += 1
	return r
print(main(list(input())))


from collections import Counter
(s, w) = (Counter(input()), Counter('nineteen'))
f = lambda k, v: (s['n'] - 1) // 2 if k == 'n' else s[k] // v
print(max(0, min((f(k, v) for (k, v) in w.items()))))


import sys
string = sys.stdin.read()
n = 0
e = 0
i = 0
t = 0
for char in string:
	if char == 'n':
		n += 1
		continue
	if char == 'e':
		e += 1
		continue
	if char == 'i':
		i += 1
		continue
	if char == 't':
		t += 1
		continue
n = (n - 1) / 2
e = e / 3
try:
	print(int(min(n, e, i, t)))
except:
	print('0')


st = input()
n = 0
i = 0
e = 0
t = 0
for el in st:
	if el == 'n':
		n += 1
	elif el == 'i':
		i += 1
	elif el == 'e':
		e += 1
	elif el == 't':
		t += 1
if n == 0 or n == 1 or n == 2:
	rn = 0
else:
	rn = (n - 1) // 2
print(min([rn, i // 1, e // 3, t // 1]))


import itertools

def main():
	s = input()
	n = s.count('n')
	i = s.count('i')
	t = s.count('t')
	e = s.count('e')
	counter = 0
	while n >= 3 and i >= 1 and (t >= 1) and (e >= 3):
		n -= 2
		i -= 1
		t -= 1
		e -= 3
		counter += 1
	print(counter)
main()


string = str(input())
times = 0
n = 0
e = 0
t = 0
i = 0
for c in string:
	if c == 'n':
		n += 1
	elif c == 'e':
		e += 1
	elif c == 't':
		t += 1
	elif c == 'i':
		i += 1
times = int(min((n - 1) / 2, e / 3, t, i))
print(str(times))


s = input()
c = 0
res = ''
x = len(s)
for i in range(x):
	if s.find('n') >= 0:
		res += 'n'
		s = list(s)
		s[s.index('n')] = ' '
		s = ''.join(s)
	else:
		break
	if s.find('i') >= 0:
		res += 'i'
		s = list(s)
		s[s.index('i')] = ' '
		s = ''.join(s)
	else:
		break
	if s.find('n') >= 0:
		res += 'n'
		s = list(s)
		s[s.index('n')] = ' '
		s = ''.join(s)
	else:
		break
	if s.find('e') >= 0:
		res += 'e'
		s = list(s)
		s[s.index('e')] = ' '
		s = ''.join(s)
	else:
		break
	if s.find('t') >= 0:
		res += 't'
		s = list(s)
		s[s.index('t')] = ' '
		s = ''.join(s)
	else:
		break
	if s.find('e') >= 0:
		res += 'e'
		s = list(s)
		s[s.index('e')] = ' '
		s = ''.join(s)
	else:
		break
	if s.find('e') >= 0:
		res += 'e'
		s = list(s)
		s[s.index('e')] = ' '
		s = ''.join(s)
	else:
		break
while len(res) > 1:
	if res[:8] == 'nineteen':
		c += 1
	res = res[7:]
print(c)


s = input('')
d = {'n': 0, 'i': 0, 'e': 0, 't': 0}
for c in s:
	try:
		d[c] += 1
	except:
		pass
d['n'] = (d['n'] - 1) // 2
d['e'] = d['e'] // 3
cnt = min(d.values())
if cnt < 0:
	cnt = 0
print(cnt)


s = input()
flag = 0
c = 0
n = s.count('n')
i = s.count('i')
e = s.count('e')
t = s.count('t')
while n > 0 and i > 0 and (e > 0) and (t > 0):
	if flag == 0:
		n -= 3
		flag = 1
	else:
		n -= 2
	i -= 1
	e -= 3
	t -= 1
	if n >= 0 and i >= 0 and (e >= 0) and (t >= 0):
		c += 1
print(c)


try:
	line = input()
	n = line.count('n')
	i = line.count('i')
	e = line.count('e')
	t = line.count('t')
	c = 0
	z = 1
	f = 0
	while z != 0:
		if f == 0:
			n = n - 3
			f = 1
		else:
			n = n - 2
		e = e - 3
		t = t - 1
		i = i - 1
		if n >= 0 and e >= 0 and (t >= 0) and (i >= 0):
			c = c + 1
			continue
		else:
			break
	print(c)
except:
	pass


s = input()
ne = s.count('e') // 3
nn = (s.count('n') - 1) // 2
ni = s.count('i')
nt = s.count('t')
m = min(ne, nn, ni, nt)
if m < 0:
	m = 0
print(m)


n = input().split()
temp = [(n[0].count('n') - 1) // 2, n[0].count('i'), n[0].count('e') // 3, n[0].count('t')]
if min(temp) < 0:
	print(0)
else:
	print(min(temp))


line = input()
n_count = 0
i_count = 0
e_count = 0
t_count = 0
for c in line:
	if c == 'n':
		n_count += 1
	elif c == 'i':
		i_count += 1
	elif c == 'e':
		e_count += 1
	elif c == 't':
		t_count += 1
prop_i = int(i_count / 1)
prop_e = int(e_count / 3)
prop_t = int(t_count / 1)
prop_n = 0
if n_count >= 3:
	prop_n = 1 + int((n_count - 3) / 2)
min_prop = prop_n
if prop_i < min_prop:
	min_prop = prop_i
if prop_e < min_prop:
	min_prop = prop_e
if prop_t < min_prop:
	min_prop = prop_t
print(min_prop)


a = str(input())
ans = 0
numbi = 0
numbn = 0
numbe = 0
numbt = 0
for i in a:
	if i == 'i':
		numbi += 1
	elif i == 'n':
		numbn += 1
	elif i == 'e':
		numbe += 1
	elif i == 't':
		numbt += 1
if numbi >= 1 and numbn >= 3 and (numbe >= 3) and (numbt >= 1):
	ans += 1
	b = min(int(numbi - 1), int((numbn - 3) / 2), int((numbe - 3) / 3), int(numbt - 1))
	ans += b
print(ans)


s = input()
N = 'nite'
count = []
for i in N:
	count.append(s.count(i))
if 0 in count:
	print(0)
else:
	print(min((count[0] - 1) // 2, count[1], count[2], count[3] // 3))


s = input()
a = [0] * 26
b = [0] * 26
for c in 'nineteen':
	a[ord(c) - ord('a')] += 1
for c in s:
	b[ord(c) - ord('a')] += 1
s = 0
if all((y >= x for (x, y) in zip(a, b))):
	s += 1
	for i in range(26):
		b[i] -= a[i]
	a[ord('n') - ord('a')] -= 1
	s += min((y // x for (x, y) in zip(a, b) if x > 0))
print(s)


import math
s = str(input())
ncount = 0
icount = 0
tcount = 0
ecount = 0
nvalid = 0
for c in s:
	if c == 'n':
		ncount += 1
	if c == 'i':
		icount += 1
	if c == 't':
		tcount += 1
	if c == 'e':
		ecount += 1
if ncount > 3:
	nvalid += math.floor((ncount - 1) / 2)
elif ncount == 3:
	nvalid = 1
print(min(nvalid, icount, tcount, math.floor(ecount / 3)))


str = input()
array = [0, 0, 0, 0]
for i in range(len(str)):
	if str[i] == 'n':
		array[0] += 1
	elif str[i] == 'i':
		array[1] += 1
	elif str[i] == 'e':
		array[2] += 1
	elif str[i] == 't':
		array[3] += 1
if array[0] < 3 or array[1] < 1 or array[2] < 3 or (array[3] < 1):
	print('0')
else:
	sum = 1
	array[0] -= 3
	array[1] -= 1
	array[2] -= 3
	array[3] -= 1
	array[0] = int(array[0] / 2)
	array[2] = int(array[2] / 3)
	nho = 10000
	for i in array:
		nho = min(nho, i)
	print(sum + nho)


s = input()
n = s.count('n')
i = s.count('i')
e = s.count('e')
t = s.count('t')
if n < 3 or i < 1 or e < 3 or (t < 1):
	print(0)
else:
	minn = e // 3
	if i < minn:
		minn = i
	if t < minn:
		minn = t
	if (n - 1) // (3 - 1) < minn:
		minn = (n - 1) // (3 - 1)
	print(minn)


from collections import Counter
from itertools import cycle
coefficients = {'i': 1, 't': 1, 'e': 3, 'n': 3}
word = 'ninetee'
str1 = input()
chars = Counter(str1)
result = 0
test_str = ''
for char in cycle(word):
	if chars.get(char):
		test_str += char
		chars[char] -= 1
	else:
		break
	if test_str == word + 'n':
		test_str = test_str[0]
		result += 1
print(result)


s = input()
v = []
r = 0
e = 0
h = 0
c = 0
f = 0
x = 0
z = 0
for i in s:
	if i == 'n':
		e = e + 1
		if e == 3:
			e = 1
			c = c + 1
	elif i == 'i':
		f = f + 1
	elif i == 'e':
		r = r + 1
		if r == 3:
			x = x + 1
			r = 0
	elif i == 't':
		z = z + 1
v.append(c)
v.append(f)
v.append(x)
v.append(z)
v.sort()
print(v[0])


from math import floor, ceil
k = input()
n = (k.count('n') - 1) // 2
i = k.count('i')
e = k.count('e') // 3
t = k.count('t')
print(max(0, min(n, i, e, t)))


s = input()
count = [0, 0, 0, 0]
for i in s:
	if i == 'n':
		count[0] += 1
	elif i == 'i':
		count[1] += 1
	elif i == 'e':
		count[2] += 1
	elif i == 't':
		count[3] += 1
count[0] = (count[0] - 3) // 2 + 1
count[2] = count[2] // 3
x = min(count)
if x < 0:
	print('0')
else:
	print(x)


s = input()
i = 0
n = 0
e = 0
q = 0
t = 0
while i < len(s):
	if s[i] == 'n':
		n += 1
	if s[i] == 'e':
		e += 1
	if s[i] == 'i':
		q += 1
	if s[i] == 't':
		t += 1
	i += 1
a = [0, 0, 0, 0]
a[0] = (n - 1) // 2
if a[0] < 0:
	a[0] = 0
a[1] = e // 3
a[2] = q
a[3] = t
i = 0
mn = a[0]
while i < 4:
	if a[i] < mn:
		mn = a[i]
	i += 1
print(mn)


s = list(input().lower())
n = 0
t = 0
i = 0
e = 0
for k in s:
	if k == 'n':
		n = n + 1
	if k == 't':
		t = t + 1
	if k == 'e':
		e = e + 1
	if k == 'i':
		i = i + 1
p = 1
n = n - 3
n = n // 2
n = n + p
e = e // 3
p = min(n, i, e, t)
p = max(0, p)
print(p)


a = input().strip()
num_n = 0
num_e = 0
num_i = 0
num_t = 0
for i in a:
	if i == 'n':
		num_n += 1
	if i == 'e':
		num_e += 1
	if i == 'i':
		num_i += 1
	if i == 't':
		num_t += 1
num_n = int((num_n - 1) / 2)
num_e = int(num_e / 3)
print(min(num_n, num_e, num_i, num_t))


s = input()
n = s.count('n')
i = s.count('i')
e = s.count('e')
t = s.count('t')
n3 = int((n - 1) / 2)
e3 = int(e / 3)
num = n3
if i < n3:
	num = i
if e3 < num:
	num = e3
if t < num:
	num = t
print(num)


import math
a = input()
n = 0
i = 0
t = 0
e = 0
l = int(len(a))
for j in range(0, l):
	if a[j] == 'n':
		n += 1
	if a[j] == 'i':
		i += 1
	if a[j] == 'e':
		e += 1
	if a[j] == 't':
		t += 1
r = math.floor(min(i, t, e / 3, max(0, (n - 1) / 2)))
print(r)


a = input()
b = a.count('n')
c = a.count('i')
d = a.count('e')
e = a.count('t')
if b > 4:
	print(min((b - 1) // 2, c, d // 3, e))
elif b == 3 or b == 4:
	print(min(1, c, d // 3, e))
else:
	print(0)


s = input()
(n, i, e, t) = [0, 0, 0, 0]
x = 0
for c in s:
	if c == 'n':
		n = n + 1
	if c == 'i':
		i = i + 1
	if c == 'e':
		e = e + 1
	if c == 't':
		t = t + 1
while (x > 0 and n >= 2 or n >= 3) and i >= 1 and (e >= 3) and (t >= 1):
	n = n - 2 if x > 0 else n - 3
	i = i - 1
	e = e - 3
	t = t - 1
	x = x + 1
print(x)


def nineteen_count(string):
	letter_count = {}
	for letter in string:
		if letter in letter_count:
			letter_count[letter] += 1
		else:
			letter_count[letter] = 1
	if 'n' not in letter_count or 'i' not in letter_count or 'e' not in letter_count or ('t' not in letter_count):
		return 0
	return min((letter_count['n'] - 1) // 2, letter_count['i'], letter_count['e'] // 3, letter_count['t'])
print(nineteen_count(input()))


s = input()
num_n = 0
num_i = 0
num_e = 0
num_t = 0
for i in s:
	if i == 'n':
		num_n += 1
	elif i == 'i':
		num_i += 1
	elif i == 'e':
		num_e += 1
	elif i == 't':
		num_t += 1
if num_n >= 3:
	num_n = (num_n - 1) // 2
else:
	num_n = 0
num_i = num_i // 1
num_e = num_e // 3
num_t = num_t // 1
print(min(num_n, num_i, num_e, num_t))


word = 'nineteen'
string = input()
string = [s for s in string]
times = 0

def isTrue():
	global word, string, times
	for s in word:
		if s in string:
			string.remove(s)
		else:
			return
	return True
while isTrue():
	times = times + 1
	if times == 1:
		word = 'ineteen'
print(times)


s = input()
cntn = max(0, (s.count('n') - 1) // 2)
cnte = s.count('e') // 3
cnti = s.count('i')
cntt = s.count('t')
print(min(cntn, cnte, cnti, cntt))


string = str(input())
a = [str(i) for i in string]
n = a.count('n')
i = a.count('i')
e = a.count('e')
t = a.count('t')
modn = abs((n - 1) // 2)
mode = e // 3
modi = i
modt = t
print(min([modn, mode, modi, modt]))


import math

def sol():
	d = {}
	for i in 'nineteen':
		d[i] = 0
	s = input()
	for i in s:
		d[i] = d.get(i, 0) + 1
	temp_min = min(d['i'], d['e'] // 3, d['t'])
	print(min(temp_min, max(0, (d['n'] - 1) // 2)))
sol()


s = input()
form = 'nineteen'
ans = 0
flag = True
while True:
	for i in range(len(form)):
		if s.find(form[i]) == -1:
			flag = False
			break
		if i == len(form) - 1:
			ans += 1
		else:
			s = s[:s.find(form[i])] + s[s.find(form[i]) + 1:]
	if not flag:
		break
print(ans)


s = input()
mapa = dict()
for i in s:
	if i in mapa:
		mapa[i] += 1
	else:
		mapa[i] = 1
if 'n' in mapa and 'e' in mapa and ('i' in mapa) and ('t' in mapa) and (mapa['n'] > 0):
	mapa['n'] -= 1
	mynum = 0
	numN = mapa['n'] / 2
	numE = mapa['e'] / 3
	numI = mapa['i']
	numT = mapa['t']
	print(int(min(numN, numE, numI, numT)))
else:
	print(0)


s = input().strip()
letters = [0] * 30
for i in range(len(s)):
	letters[ord(s[i]) - ord('a')] += 1
ans = min(letters[ord('i') - ord('a')], letters[ord('e') - ord('a')] // 3)
ans = min(ans, letters[ord('t') - ord('a')])
ans = min(ans, (letters[ord('n') - ord('a')] - 3) // 2 + 1)
print(max(0, ans))


from collections import Counter
word = input()
counter = Counter(word)
count = 0

def checker():
	for letter in 'nineteen':
		if not counter[letter]:
			return 1
		counter[letter] -= 1
	return 0
while True:
	if checker():
		break
	count += 1
	counter['n'] += 1
print(count)


s = input()
dic = {}
for i in 'niet':
	dic[i] = s.count(i)
ans = dic['n']
if ans > int(dic['n'] / 2 - 0.5):
	ans = int(dic['n'] / 2 - 0.5)
if ans > dic['i']:
	ans = dic['i']
if ans > int(dic['e'] / 3):
	ans = int(dic['e'] / 3)
if ans > dic['t']:
	ans = dic['t']
print(ans)


a = input()

def main(s):
	n = i = e = t = _t = 0
	for c in s:
		if c == 'n':
			n += 1
		elif c == 'i':
			i += 1
		elif c == 'e':
			e += 1
		elif c == 't':
			t += 1
		if n >= 3 and i >= 1 and (e >= 3) and (t >= 1):
			n -= 2
			e -= 3
			i -= 1
			t -= 1
			_t += 1
	return _t
print(main(a))


def read_int():
	return int(input().strip())

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

def read_string():
	return input().strip()

def read_string_list(delim=' '):
	return input().strip().split(delim)
s = read_string()
uniq = 'niet'
contestants = {'n': 0, 'i': 0, 'e': 0, 't': 0}
for l in s:
	if l in uniq:
		contestants[l] += 1
outs = []
outs.append((contestants['n'] - 3) // 2 + 1)
outs.append(contestants['i'])
outs.append(contestants['e'] // 3)
outs.append(contestants['t'])
out = min(outs)
if out < 0:
	out = 0
print(out)


S = input()
n = S.count('n')
i = S.count('i')
e = S.count('e')
t = S.count('t')
(v, q) = (0, 0)
if n >= 3 and i >= 1 and (t >= 1) and (e >= 3):
	n -= 3
	i -= 1
	t -= 1
	e -= 3
	v += 1
	if n < 2 or i < 1 or t < 1 or (e < 3):
		q = 1
	while q == 0:
		n -= 2
		i -= 1
		t -= 1
		e -= 3
		v += 1
		if n < 2 or i < 1 or t < 1 or (e < 3):
			q = 1
print(v)


a = [i for i in input().strip()]
flag = 1
b = []
count = 0
try:
	while flag:
		b.append(a.remove('n'))
		b.append(a.remove('i'))
		b.append(a.remove('n'))
		b.append(a.remove('e'))
		b.append(a.remove('t'))
		b.append(a.remove('e'))
		b.append(a.remove('e'))
		b.append(a.remove('n'))
		count += 1
		a.append('n')
except:
	print(count)


res = 'n' + 'ineteen' * 105
s = input()
dic = {}
for i in res:
	dic[i] = s.count(i)
j = 0
while dic[res[j]] > 0:
	dic[res[j]] -= 1
	j += 1
print(res[:j].count('ineteen'))


st = input()
n = 0
i = 0
e = 0
t = 0
total = 0
for s in st:
	if s == 'n':
		n += 1
	elif s == 'e':
		e += 1
	elif s == 'i':
		i += 1
	elif s == 't':
		t += 1
while t >= 1 and i >= 1 and (e >= 3):
	total += 1
	i -= 1
	e -= 3
	t -= 1
d = total * 2 + 1
while d > n:
	if total < 1:
		break
	total -= 1
	d = total * 2 + 1
print(total)


phrase = input()
required = {l: 'nineteen'.count(l) for l in list(set('nineteen'))}
available = {l: phrase.count(l) for (l, n) in required.items()}
occurences = 0
if min((available[l] / n for (l, n) in required.items())) > 1:
	occurences += 1
	available = {l: available[l] - required[l] for l in available.keys()}
	required['n'] -= 1
while min((available[l] / n for (l, n) in required.items())) >= 1:
	occurences += 1
	available = {l: available[l] - required[l] for l in available.keys()}
print(occurences)


s = input()
a = []
a.append(s.count('i'))
ns = s.count('n')
a.append((ns - 1) // 2)
a.append(s.count('e') // 3)
a.append(s.count('t'))
ans = min(a)
if ans < 0:
	print(0)
else:
	print(ans)


s = input()
a1 = s.count('n')
a2 = s.count('i')
a3 = s.count('t')
a4 = s.count('e')
c = (a1 - 1) // 2
c1 = a4 // 3
x = [c, a2, a3, c1]
if c == 0 or a1 == 0:
	print('0')
else:
	print(min(x))


import collections

def do():
	s = str(input())
	count = collections.Counter(s)
	d = {'i': 1, 'e': 3, 't': 1}
	r = min((count[i] // d[i] for i in d))
	return min((count['n'] - 1) // 2, r)
print(max(0, do()))


s = input()
l = len(s)
letters = [0, 0, 0, 0]
w = 0
for i in range(l):
	if s[i] == 'n':
		letters[0] += 1
	elif s[i] == 'i':
		letters[1] += 1
	elif s[i] == 'e':
		letters[2] += 1
	elif s[i] == 't':
		letters[3] += 1
	else:
		pass
i = 0
w = min(letters[1], letters[2] // 3, letters[3])
l = letters[0]
while l > 1:
	l -= 2
	i += 1
if i == 0:
	print('0')
else:
	letters[0] += i - 1
	print(min(letters[0] // 3, w))


text = input()
letters = ['n', 'i', 'n', 'e', 't', 'e', 'e', 'n']
my_string = ''
counter = 0
while len(letters):
	if (counter + 1) % len(letters) == 0 and counter != 0:
		counter = 0
	index = text.find(letters[counter])
	if index >= 0:
		my_string += text[index]
	else:
		index_ = letters.index(letters[counter])
		letters.pop(index_)
		counter = 0
	text = text.replace(text[index], '*', 1)
	counter += 1
sum = 0
word = ''
for letter in my_string:
	word += letter
	if word == 'nineteen':
		sum += 1
		word = 'n'
print(sum)


s = input()
if len(s) == 0:
	print(0)
else:
	(n_b, i_b, e_b, t_b) = (2, 1, 3, 1)
	f = lambda s: [s.count(x) for x in ['n', 'i', 'e', 't']]
	count = lambda n, i, e, t: min((n - 1) // n_b, i // i_b, e // e_b, t // t_b)
	print(max(count(*f(s)), 0))


temp = input()
n = 0
i = 0
e = 0
t = 0
for k in list(temp):
	if k == 'n':
		n = n + 1
	if k == 'i':
		i = i + 1
	if k == 'e':
		e = e + 1
	if k == 't':
		t = t + 1
res = []
if n < 3:
	res.append(int(0))
elif n >= 3 and n <= 4:
	res.append(int(1))
elif n >= 5 and n <= 6:
	res.append(int(2))
elif n >= 7 and n <= 8:
	res.append(int(3))
elif n >= 9 and n <= 10:
	res.append(int(4))
elif n >= 11 and n <= 12:
	res.append(int(5))
elif n >= 13 and n <= 14:
	res.append(int(6))
elif n >= 15 and n <= 16:
	res.append(int(7))
elif n >= 17 and n <= 18:
	res.append(int(8))
elif n >= 19 and n <= 20:
	res.append(int(9))
elif n >= 21 and n <= 22:
	res.append(int(10))
elif n >= 23 and n <= 24:
	res.append(int(11))
elif n >= 25 and n <= 26:
	res.append(int(12))
res.append(int(i / 1))
res.append(int(e / 3))
res.append(int(t / 1))
print(min(res))


word = input()
n = 0
i = 0
t = 0
e = 0
for number in word:
	if number == 'n':
		n += 1
	if number == 'i':
		i += 1
	if number == 't':
		t += 1
	if number == 'e':
		e += 1
e = e // 3
sum = 0
if n >= 5:
	while n >= 3:
		sum += 1
		n = n - 2
	print(min(sum, i, t, e))
elif n < 3:
	print(min(0, i, t, e))
else:
	print(min(1, i, t, e))


word = input()
if word.count('n') > 1:
	ns = 1 + (word.count('n') - 3) // 2
else:
	ns = 0
lst = [ns, word.count('e') // 3, word.count('i'), word.count('t')]
print(min(lst))


word = input()
letters_of_interests = ''.join([x if x in 'niet' else '' for x in word])
nines = ''
count = 0
while True:
	if count == 0:
		i = letters_of_interests.find('n')
		if i == -1:
			break
		else:
			letters_of_interests = letters_of_interests[0:i] + letters_of_interests[i + 1:]
	i = letters_of_interests.find('i')
	if i == -1:
		break
	else:
		letters_of_interests = letters_of_interests[0:i] + letters_of_interests[i + 1:]
	i = letters_of_interests.find('n')
	if i == -1:
		break
	else:
		letters_of_interests = letters_of_interests[0:i] + letters_of_interests[i + 1:]
	i = letters_of_interests.find('e')
	if i == -1:
		break
	else:
		letters_of_interests = letters_of_interests[0:i] + letters_of_interests[i + 1:]
	i = letters_of_interests.find('t')
	if i == -1:
		break
	else:
		letters_of_interests = letters_of_interests[0:i] + letters_of_interests[i + 1:]
	i = letters_of_interests.find('e')
	if i == -1:
		break
	else:
		letters_of_interests = letters_of_interests[0:i] + letters_of_interests[i + 1:]
	i = letters_of_interests.find('e')
	if i == -1:
		break
	else:
		letters_of_interests = letters_of_interests[0:i] + letters_of_interests[i + 1:]
	i = letters_of_interests.find('n')
	if i == -1:
		break
	else:
		letters_of_interests = letters_of_interests[0:i] + letters_of_interests[i + 1:]
	count += 1
print(count)


str = input()
ans = min(str.count('i'), str.count('t'), str.count('e') // 3, max(0, (str.count('n') - 1) // 2))
print(ans)


vvod = input()
wn = 0
wi = 0
we = 0
wt = 0
for elem in vvod:
	if elem == 'n':
		wn += 1
	elif elem == 'i':
		wi += 1
	elif elem == 'e':
		we += 1
	elif elem == 't':
		wt += 1
if wn >= 5 and wn % 2 == 1:
	wn = wn // 2
elif wn >= 5 and wn % 2 == 0:
	wn = wn // 2 - 1
else:
	wn = wn // 3
we = we // 3
minw = min(min(wn, wi), min(we, wt))
print(minw)


NINETEEN = 'nineteen'
s = input()
s += 'n' * ((s.count('n') - 2) // 2)
chars = set(NINETEEN)
most = min(list(map(lambda c: s.count(c) // NINETEEN.count(c), chars)))
print(most)


a = input()
n = int(0)
ii = int(0)
t = int(0)
e = int(0)
for i in range(len(a)):
	if a[i] == 'n':
		n += 1
	if a[i] == 'i':
		ii += 1
	if a[i] == 'e':
		e += 1
	if a[i] == 't':
		t += 1
if n > 3:
	n = int((n - 3) / 2) + 1
else:
	n = int(n / 3)
print(min(n, int(e / 3), ii, t))


palavra = input()
n = palavra.count('n')
i = palavra.count('i')
e = palavra.count('e')
t = palavra.count('t')
lista = []
if n > 3:
	contador = 1
	n = n - 3
	contador = contador + n // 2
	lista.append(contador)
else:
	lista.append(n // 3)
lista.append(i // 1)
lista.append(e // 3)
lista.append(t // 1)
lista.sort()
print(lista[0])


s = input()
lists = [i for i in s]
if len(s) < 8:
	print(0)
else:
	nno = lists.count('n')
	ino = lists.count('i')
	eno = lists.count('e')
	tno = lists.count('t')
	k = []
	ncalc = 0
	if nno >= 3:
		ncalc = 1 + (nno - 3) // 2
	k.append(ncalc)
	k.append(ino)
	k.append(int(eno / 3))
	k.append(tno)
	print(min(k))


s = input()
pr = []
e = s.count('e')
n = s.count('n')
t = s.count('t')
i = s.count('i')
pr.append(int((n - 1) / 2))
pr.append(i)
pr.append(int(e / 3))
pr.append(t)
print(min(pr))


s = input()
k = {i: s.count(i) for i in set(list(s))}
p = min([k.get('e', 0) // 3, k.get('i', 0), k.get('t', 0)])
w = k.get('n', 0)
w = (w - 3) // 2 + 1
w = max(0, w)
print(min(p, w))


def find_occurs(s, world):
	exit = False
	cant_occurs = 0
	index = 0
	capture = 0
	while not exit:
		flag = 0
		for i in range(len(world)):
			try:
				index = s.index(world[i])
				s[index] = '|'
				flag += 1
			except ValueError as err:
				break
		if flag == len(world):
			s.append(world[0])
			cant_occurs += 1
		else:
			exit = True
	return cant_occurs
world = 'nineteen'
s = list(input())
print(find_occurs(s, world))


s = 'nineteen'
str = input()
c = 0
j = 0
check = True
x = True
while check:
	check = False
	for i in range(len(str)):
		if str[i] == s[j % 8]:
			if j % 8 == 7:
				x = False
			else:
				str = str[:i] + str[i + 1:]
			check = True
			j += 1
			if j % 8 == 0:
				c += 1
			break
print(c)


def nineteen_cf():
	from collections import Counter
	s = input()
	c = Counter()
	r = 0
	a = 3
	for i in s:
		c[i] += 1
		if c['n'] >= a and c['e'] >= 3 and (c['i'] >= 1) and (c['t'] >= 1):
			c['n'] -= a
			c['e'] -= 3
			c['i'] -= 1
			c['t'] -= 1
			a = 2
			r += 1
	return r
print(nineteen_cf())


c = input()
d = {'n': 0, 'i': 0, 't': 0, 'e': 0}
for i in c:
	if any([i == x for x in d.keys()]):
		d[i] += 1
if d['n'] // 3 == 0:
	print(min(d['n'] // 3, d['i'], d['t'], d['e'] // 3))
else:
	print(min((d['n'] - 1) // 2, d['i'], d['t'], d['e'] // 3))


a = {}
s = 'ineteen'
b = input()
for i in s:
	a[i] = b.count(i)
l = 'n'
k = -1
while a[l] > 0:
	a[l] -= 1
	k += 1
	l = s[k % 7]
print(max(0, k) // 7)


s = input()
abs = 'nineteen'
ab = [0, 0, 0, 0]
for i in s:
	if i == 'n':
		ab[0] += 1
	if i == 'i':
		ab[1] += 1
	if i == 'e':
		ab[2] += 1
	if i == 't':
		ab[3] += 1
if min((ab[0] - 1) // 2, ab[1], ab[2] // 3, ab[3]) <= 0:
	print(0)
else:
	print(min((ab[0] - 1) // 2, ab[1], ab[2] // 3, ab[3]))