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: interview

Starter code:

Solutions:
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]))

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)

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)

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)

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))

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)

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()
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)

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())))

st = input()
a = {'n':0, 'i':0, 'e':0, 't':0}
# n*3131-(n-1)*1000 = 2n+1,n,3n,n
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))


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'))

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))


# 1481305185129


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)

# 1481311408782


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


#if vn>1:
#	vn+=(vn-1)

ans = max(0, min(vn, ve, vi, vt))

ans = int(ans)

print(ans)

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


#if vn>1:
#	vn+=(vn-1)

ans = max(0, min(vn, ve, vi, vt))

ans = int(ans)

print(ans)
# 1481824118256


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)


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]))

# 1502215214848


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)));
# 1502216507489


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]))

# 1502217389696


def v_19(s):
    a = [0, 0, 0, 0]
    #    n  e  i  t

    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))

# 1502218585911


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'))

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())))


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]))))


# python 3
"""
Read tutorial, graph the moves, still don't understand this problem
"""


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():
    """
    Inside of this is the test. 
    Outside is the API
    """

    string = input()

    print(nineteen(string))

__starting_point()

s = input().strip()
n = s.count('n')
e = s.count('e') // 3
i = s.count('i')
t = s.count('t')

#print(n, e, s.count('e'), i, 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