	#include <bits/stdc++.h>
	using namespace std;
	#define M (int)1e9
	#define pi 3.1415926536
	#define all(a) a.begin(),a.end()
	#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	#define flp(i,x,y) for(long long int i=x;i<y;i++)
	#define ll long long int
	#define MOD (long long int)(1000000007)
	#define pb push_back
	vector <int> SieveOfEratosthenes(int n)
	{
	    vector<int> ans;
	    bool prime[n+1];
	    memset(prime, true, sizeof(prime));

	    for (int p=2; p*p<=n; p++)
	    if (prime[p] == true)
	    for (int i=p*p; i<=n; i += p)
	    prime[i] = false;

	  	for (int p=2; p<=n; p++)
	    if (prime[p])
	    ans.push_back(p);
		return ans;
	}

	vector <int> fib(int n)
	{
		vector<int> ans;
		int x=0,y=1,l=1;
		ans.push_back(x);
		ans.push_back(y);
		while(l<n)
		{
			l=x+y;
			x=y;y=l;
			ans.push_back(l);
		}
		return ans;
	}

	bool isPrime(ll n)
	{
		if (n <= 1) return false;
		if (n <= 3) return true;

		if (n%2 == 0 || n%3 == 0) return false;

		for (ll i=5; i*i<=n; i=i+6)
			if (n%i == 0 || n%(i+2) == 0)
			return false;

		return true;
	}

	long long power(int n,int k)
	{
		if(k==0)	return 1;
		else return (n*power(n,k-1)%1000000007);
	}

	long long nCr(int n,int r)
	{
		if(n==r)	return 1;
		else if (r==0)	return 1;
		else return ((nCr(n-1,r-1)+nCr(n-1,r))%998244353);
	}

	int sdigit(int x)
	{
		int ans=0;
		while(x)
		{
			ans+=x%10;
			x/=10;
		}
		return ans;
	}

	long long lcm(int a,int b)
	{
		return ((long long)a*(long long)b)/__gcd(a,b);
	}

	 pair<int,int> subArraySum(int arr[], int n, int sum)
	{
	    int curr_sum = arr[0], start = 0, i;

	    for (i = 1; i <= n; i++)
	    {
	        while (curr_sum > sum && start < i - 1)
	        {
	            curr_sum = curr_sum - arr[start];
	            start++;
	        }

	        if (curr_sum == sum)
	        {
	            //cout << "Sum found between indexes "
	              //   << start << " and " << i - 1;
	            return make_pair(start,i-1);
	        }

	        if (i < n)
	        curr_sum = curr_sum + arr[i];
	    }

	    return make_pair(-1,-1);
	}

	int bs(int a[],int b,int l,int r)
	{
		int mid=(l+r)/2;
		if(l>r)	return -1;
		if(a[mid]==b||l==r)	return mid;
		if(a[mid]>b)	return bs(a,b,l,mid-1);
		else return bs(a,b,mid+1,r);
	}

	int divideandconquerbc(int a[],int l,int r)
	{
		if(l>=r)	return 0;
		int mid=(l+r)/2,ans=0;
		ans+=divideandconquerbc(a,l,mid);
		ans+=divideandconquerbc(a,mid+1,r);
		int x=r-l+1,y=mid-l+1;
		int c[x];
		int i=0,j=0;
		for(int k=0;k<x;k++)
		{
			if((a[l+i]<=a[mid+1+j]&&i<y)||j>=x-y)	{c[k]=a[l+i];i++;}
			else {c[k]=a[mid+1+j];j++;ans+=y-i;}
			//cout<<c[k]<<" "<<ans<<endl;

		}
		for(int k=l;k<=r;k++)
			a[k]=c[k-l];
	    return ans;
	}

	void explore(bool a[],vector<vector <int> >adj,int u)
	{
		if(a[u-1])	return;
		else	a[u-1]=true;
		for(int i=0;i<adj[u-1].size();i++)
		{
			explore(a,adj,adj[u-1][i]+1);
		}
	}
	long long  gcd(int a,int b)
	{
	    if (b==0) return a;
	    return gcd(b,a%b);
	}

	double startTime;
	double getCurrentTime() {
		return ((double)clock() - startTime) / CLOCKS_PER_SEC;
	}
	/*int dfs(int u,int f)
	{
		depth[u]=depth[f]+1;size[u]=1;
		for (int i=0;i<conj[u].size();++i)
		{
			if ((v=conj[u][i])==f)continue;
			size[u]+=dfs(v,u);
		}
		det[u]=size[u]-depth[u];return size[u];*/
void out(ll n)
{
	string a,b;
    cin >>a>>b;
    vector<int> v1,v2;
    a+='0';
    b+='0';
    flp(i,1,n+1)
    {
    	if(a[i]!=a[i-1])
    		v1.push_back(i);
    	if(b[i]!=b[i-1])
    		v2.push_back(i);

    }
    cout<<v1.size()+v2.size()<<" ";
    flp(i,0,v1.size())
    cout<<v1[i]<<" ";
    flp(i,0,v2.size())
    cout<<v2[v2.size()-i-1]<<" ";
    cout<<"\n";

}

int point(char A, char B)   {
    if(A == B)  return 0;

    if(A == 'R')    {
        if(B == 'P')    return -1;
        else    return 1;
    }

    if(A == 'P')    {
        if(B == 'R')    return 1;
        else    return -1;
    }

    else    {
        if(B == 'R')    return -1;
        else    return 1;
    }
}
/*int mex(int r[])
{
	int n=sizeof(r)/sizeof(r[0]);
	int b[n+1]={};
	int st=0;
	flp(i,0,n)
	{
		b[a[i]]=1;
		while(b[st]==1)
			st++;
	}
	return st;

}*/
/*ll modInverse(ll n, ll p)
{
    return power(n, p-2, p);
}*/
int good (int n,string s,char ch)
{
	if (n==1){
		if (s[0]==ch) return 0;
		else return 1;
	}else{
		int f1=0,f2=0;
		for (int i=0;i<n/2;i++){
			if (s[i]==ch) f1++;
			if (s[n-i-1]==ch) f2++;
		}
		string s1=s.substr(n/2,n);
		int ans1= (n/2)-f1 + good(n/2,s1,ch+1);
		string s2=s.substr(0,n/2);
		int ans2= (n/2)-f2 + good(n/2,s2,ch+1);
		return  min(ans1,ans2);

	}
}
	int main()
	{
		//#ifndef ONLINE_JUDGE
		//freopen("input.txt","r",stdin);
		//freopen("ou.txt","w",stdout);
		//#endif
		fastio
		 ll T,i,n;
	//long	double ar;
	T=1;
		//cin>>T;
		bool res=false;
	//	ctr=1;
		int l;
		while(T--)
		{
			res=false;
			 string s;
			 int k,d,cnt=0;
			 cin>>s;
		//	 cout<<s<<"\n";
			 if(s.length()>=8)
			 {
			 flp(i,0,s.length()-8+1)
			 {
			 //	cout<<"entry";
			 	if(s.substr(i,8)=="nineteen") cnt++;
			 }
				}
			 //sort(all(s));
			 int cnti=0,cntn=0,cnte=0,cntt=0;
			 flp(i,0,s.length())
			 {
			 	if(s[i]=='i') cnti++;
			 	else if(s[i]=='e') cnte++;
			 	else if(s[i]=='n') cntn++;
			 	else {
			 		if(s[i]=='t') cntt++;
			 	}
			 }
			// cout<<cnte<<" "<<cnti<<" "<<cntn<<cnt<<" "<<cntt<<" "<<cnt<<"\n";
			 cnti/=1;
			cnte/=3;
			 cntt/=1;
			//cout<<cnte<<" "<<cnti<<" "<<cntn<<cnt<<" "<<cntt<<" "<<cnt<<"\n";
			 cout<<max(cnt,min({cnti,cnte,((cntn-1)/2),cntt}))<<"\n";

		}
		return 0;
				}

#include<cstdio>
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<fstream>
using namespace std;
int main()
{
	char c[101];
	cin>>c;
	int n=0,j=0,t=0,e=0;
	for(int i=0;i<strlen(c);i++)
	{
		if(c[i]=='n')
		{
			n++;
		}
		if(c[i]=='i')
		{
			j++;
		}
		if(c[i]=='e')
		{
			e++;
		}
		if(c[i]=='t')
		{
			t++;
		}
	}
	n=(n-1)/2;
	e/=3;
	cout<<min(min(min(n,t),j),e);
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main(){
	char c[101];
	int n = 0,i = 0,t = 0,e = 0,ans = 1;
	while ( cin >> c[ans] )
	{
		if ( c[ans] == 'n' )
			n++;
        if ( c[ans] == 'i' )
			i++;
        if ( c[ans] == 'e' )
			e++;
        if ( c[ans] == 't' )
			t++;
		ans++;
	}
	int minn = 32767;
	n = ( n - 1 ) / 2;
	e /= 3;
	if ( n < minn )
		minn = n;
	if ( i < minn )
		minn = i;
	if ( t < minn )
		minn = t;
	if ( e < minn )
		minn = e;
	cout << minn;
	return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iostream>
#include <functional>
#include <time.h>
#include <cmath>

using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back

ll EPS = 1LL << 60;
double PI = 3.14159265358979323846;

__int64 abss(__int64 h)
{
  if (h < 0)
  {
    return -h;
  }
  return h;
}

__int64 ceill(__int64 x, __int64 y)
{
  if (x % y != 0)
  {
    return (x / y) + 1;
  }
  return x / y;
}

ll n, m, k;

int Xl[10] = {1, -1, 0, 0};
int Yl[10] = {0, 0, -1, 1};

const int MAXN = 1000010;

int a[MAXN];

int convert(int n,int base)
{
    int sum = 0;
    while (n != 0)
    {
        sum += n % base;
        n = n / base;
    }
    return sum;
}

int gcd (int a, int b) {
	return b ? gcd (b, a % b) : a;
}

int main()
{
	//freopen("island2.in", "r", stdin);
	//freopen("island2.out", "w", stdout);
	string str;
	cin >> str;
	string need = "nineteen";
	int n = str.size();
	int ans = 0;
	for (int i = 0; i < n; i++)
	{
		if (str[i] == 'n')
		{
			a[0]++;
		}
		if (str[i] == 'i')
		{
			a[1]++;
		}
		if (str[i] == 'e')
		{
			a[2]++;
		}
		if (str[i] == 't')
		{
			a[3]++;
		}
	}
	a[2] /= 3;
	ans = min(min(a[1], a[3]), a[2]);
	if (a[0] < 3)
	{
		cout << "0";
		return 0;
	}
	if (a[0] == 3)
	{
		cout << min(ans, 1);
		return 0;
	}
	int d = 1;
	a[0] -= 3;
	while (a[0] > 1)
	{
		d++;
		a[0] -= 2;
	}
	ans = min(ans, d);
	cout << ans;
}

#include <iostream>
#include <string>
using namespace std;

int main() {
	int n = 0, i = 0, e = 0, t = 0, count = 0;
	string A;
	cin >> A;
	for (int h = 0; h < A.size(); ++h) {
		if (A[h] == 'n') ++n;
		else if (A[h] == 'e') ++e;
		else if (A[h] == 'i') ++i;
		else if (A[h] == 't') ++t;
	}
	while (i > 0 && e > 0 && n > 0 && t > 0) {
		 if (n > 2 && i >= 1 && e >= 3 && t >= 1) {
			++count;
			n -= 2;
			--i;
			e -= 3;
			--t;
		}
		else {
			break;
		}
	}
	cout << count;
}

#include <iostream>

#include<string>
using namespace std;

void main()
{
	string str;
	cin >> str;

	int n = 0, I = 0, t = 0, e = 0;
	for (int i = 0; i < str.length(); i++)
	{
		if (str[i]=='n')
		{
			n++;
		}
		else if(str[i]=='i')
		{
			I++;
		}
		else if (str[i]== 't')
		{
			t++;
		}
		else if (str[i]== 'e')
		{
			e++;
		}
	}
	int min = I < t ? I : t;
	if (e/3<min)
	{
		min=e/ 3;
	}

	if (n<(min*2)+1)
	{
		//min = (n / 2);
		for (int i = 0; i*2+1<=n; i++)
		{
			min = i;
		}
	}
	if (min<0)
	{
		min = 0;
	}

//if (n >= 3)
//{
//	int maxn = min * 3;
//	int minn = maxn - (min - 1);
//	if (n >= minn && n <= maxn)
//	{
//		if ()
//	}
//}

	cout << min;
	//cout <<n<<I<<t<<e <<min;
}

#include <iostream>
#include <cstdio>
#include <list>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdlib>
#include <set>
#include <map>
#include <vector>
#include <deque>
#include <queue>
#include <climits>
#include <unordered_map>
#define all(v) v.begin(), v.end()
#define ll long long
#define READ(f) freopen (f, "r", stdin)
#define WRITE(f) freopen (f, "w", stdout)
#define pb push_back
#define mp make_pair
#define foreach(it, S) for(__typeof (S.begin()) it = S.begin(); it != S.end(); it++)
#define inc(i, x, n) for(int i=(int)x;i<=(int)n;i++)
#define dec(i, n, x) for(int i=(int)n;i>=(int)x;i--)
#define F first
#define S second

using namespace std;

const int MAXN = 1e5 + 256;
const int N = 1256;
const int INF = int (1e9);

unordered_map < char, int > mm;
string s, k = "nineteen";
int mn = INF, ans;

int main () {
    ios_base :: sync_with_stdio (false);
	#ifdef accepted
		READ(".in");
		WRITE(".out");
	#endif

	cin >> s;

	for (int i = 0; i < s.size(); ++i) {
		mm[s[i]]++;
	}
	while (1) {
		for (int i = 0; i < k.size(); ++i) {
			mm[k[i]]--;
			if (mm[k[i]] < 0) {
				cout << ans;
				return 0;
			}
		}
		mm['n']++;
		ans++;
	}

    return 0;
}

#include <iostream>
#include <string>
using namespace std;
int main(){
    string X;
    cin>>X;
    char y[4]={'n','i','t','e'};
    int c,arr[4],f=0;
    for(int I=0;I<4;I++){
            c=0;
        for(int i=0;i<X.size();i++){
            if(y[I]==X[i]){
                c++;
            }
    }
    arr[f]=c;
    f++;
    }
    cout<<min(min((arr[0]-1)/2,arr[1]),min((arr[2]),arr[3]/3))<<endl;
    return 0;
}

#include<iostream>
#include<string>
#include<memory.h>
#include<cmath>
#include<math.h>
#include<algorithm>
using namespace std;
int main()
{
    string st;
    int n=0,I=0,e=0,t=0,count=0;
    cin>>st;
    for(int i=0;i<=st.length()-1;i++)
    {
        if(st[i]=='n')n++;
                if(st[i]=='i')I++;
                        if(st[i]=='t')t++;
                                if(st[i]=='e')e++;
    }
   /* cout<<"n = "<<n<<endl;
    cout<<"i = "<<I<<endl;
    cout<<"t = "<<t<<endl;
    cout<<"e = "<<e<<endl;*/

                                while(n>=3 && e>=3 && I>=1 && t>=1)
                                {
                                count++;
                                n=n-2;
                                e=e-3;
                                I--;
                                t--;
                                }
                                cout<<count<<endl;
    return 0;
}

#include<bits/stdc++.h>

using namespace std;

#define pb                     push_back
#define ll                     long long
#define forn(i,n)              for(int i=0; i<(int)n; i++)
#define forn1(i,n)              for(int i=1; i<=(int)n; i++)

#define sfd(a)                 scanf("%d", &a)
#define sffd(a,b)              scanf("%d%d", &a, &b)
#define sffl(a,b)              scanf("%lld%lld", &a,&b)
#define sfl(a)                 scanf("%lld", &a)

#define pii                    pair<int , int>
#define pll                    pair<ll , ll>
#define ff                     first
#define ss                     second
#define mem(a, val)            memset(a, val, sizeof(a))
#define all(x)                 (x).begin(), (x).end()

#define mx                     200005
#define INF_mx                 1e18
//#define mod                     998244353
#define gcd(a,b)               __gcd(a, b)
#define lcm(a,b)               (a*b)/__gcd(a,b)
#define PRINT                  cout<<"hi"<<endl
#define PI acos(-1)
#define fast_in_out          ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define Q    int q; cin>>q; while(q--)

int main()
{
    fast_in_out;

     string s;
     cin>>s;

     map<char , int>mp;

     for(int i=0; i<s.size(); i++)
     {
         mp[s[i]]++;

     }

     int mn=110;

     if(mn>mp['i']) mn=mp['i'];
     if(mn>mp['t']) mn=mp['t'];
     if(mn>mp['e']/3) mn=mp['e']/3;

int tm=(mp['n']-2)/2;

           if(mn>(mp['n']+tm)/3 ) mn=(mp['n']+tm)/3;

     cout<<mn<<endl;

    return 0;
}

#include <stdio.h>
#include <algorithm>
#include <vector>
#include <math.h>
#include <map>
#include <string>
using namespace std;
int n,a[30];
char c[107];
void solve(){
    int i,j,m,b,l=0,ans=0,n,e,t;
    for(i=0;i<30;i++){
        a[i]=0;
    }
    n=strlen(c);
    for(i=0;i<n;i++){
        a[c[i]-'a']++;
    }
    n=a['n'-'a']/3;
    if(a['n'-'a']>3){
        n=1+((a['n'-'a']-3)/2);
    }
    i=a['i'-'a'];
    e=a['e'-'a']/3;
    t=a['t'-'a'];
    ans=min(min(n,i),min(e,t));
    printf("%d\n",ans);
}
int main() {
    #pragma comment(linker, "/STACK:67108864")
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "rt", stdin);
    freopen("output.txt", "wt", stdout);
    #endif
    while(gets(c)){
        solve();
    }
    return 0;
}

#include <iostream>
#include<string>
#include<stdio.h>
#include<map>
using namespace std;
int main() {
    //freopen("input.in","rt",stdin);
    //  freopen ("myfile.txt","w",stdout);
    string s ;
    cin >> s ;
    map<char , int >  m ;
    for ( int i = 0 ;i <s.length() ; i++)
        m[s[i]]++;
    bool f = 0 ;
    int r = 0 ;
    while (     m['n'] >=3 ) {
        m['n']-=3;
        m['n']++;
        f= 1 ;
        r++;
    }
    m['e']/=3 ;
    //  cout << m['n'] << " " <<  m['e'] << " " << m['i'] << " " << m['t'] << endl;
    cout << min (min (r , m['e']) , min (m['i'] , m['t']) ) << "\n";

}

#include <iostream>
#include <string>
#include <algorithm>
#include <ctime>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <conio.h>
#include <fstream>

#include <map>
#include <set>
#include <climits>
#include <queue>

using namespace std;

#define SORT(v)			sort(v.begin(), v.end())
#define REVERSE(v)		reverse(v.begin(), v.end())
#define FOR(n)			for(int i = 0; i < n; i++)

int main() {
	//ifstream cin; cin.open("input.txt");

	string text;
	getline(cin, text);

	vector<int> ltr(4);

	FOR(text.size()) {
		if (text[i] == 'n') ltr[0]++;
		else if (text[i] == 'e') ltr[1]++;
		else if (text[i] == 'i') ltr[2]++;
		else if (text[i] == 't') ltr[3]++;
	}

	cout << min(ltr[3], min(ltr[2], min(ltr[1] / 3, (ltr[0] - 1) / 2))) << endl;
}

#include<iostream>
#include<cstdio>
#include<cstring>
#define maxn 1000
using namespace std;
char ch[maxn];
int ma[maxn];
int n;
int main()
{
    scanf("%s",ch+1);
    n=strlen(ch+1);
    for(int i=1;i<=n;i++)
    {
        ma[ch[i]]++;
    }
    int u = max((ma['n']-1)>>1,0);
    int v=min(ma['i'],min(ma['e']/3,ma['t']));
    //int vv= min(u,v);
    ma['n']+=v-1;
    //cout<<ma['e']<<" "<<ma['t']<<" "<<u<<endl;
    //u = (ma['n']-1)>>1;
    printf("%d\n",min(u,v));
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
char s[105];
int n,i,e,t;
int main()
{
    scanf("%s",s+1);
    int len=strlen(s+1);
    for(int w=1;w<=len;w++)
    {
        if(s[w]=='n') n++;
        if(s[w]=='i') i++;
        if(s[w]=='e') e++;
        if(s[w]=='t') t++;
    }
    int ans=min(min(min(t,i),e/3),(n-1)/2);
    printf("%d\n",ans);
    return 0;
}

#include <bits/stdc++.h>

#define pb push_back
#define F first
#define S second
#define ll long long
#define ld long double
#define endl '\n'

using namespace std;

const ll N=1000000000;
//ld a[100][100];
//ld b[100][100];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //srand(time(0));
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    string s;
    map<char,int>mp;
    mp['i']=0;
    mp['n']=0;
    mp['e']=0;
    mp['t']=0;
    cin>>s;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='n'||s[i]=='i'||
           s[i]=='e'||s[i]=='t')mp[s[i]]++;
    }
    if(mp['n']>=1)
        mp['n']-=1;
    mp['n']/=2;

    mp['e']/=3;
    int ma=N;
    for(auto to:mp)
    {
        ma=min(ma,to.S);
        //cout<<to.F<<' '<<to.S<<endl;
    }
    cout<<ma;
    return 0;
}

#include <iostream>
using namespace std;

int main() {
	char str[105];
	cin >> str;
	int n = 0, i = 0, e = 0, t = 0;
	int counter = 0;
	for(int j = 0; str[j] != '\0'; j++)
	{
		if(str[j] == 'n')
			n++;
		if(str[j] == 'i')
			i++;
		if(str[j] == 't')
			t++;
		if(str[j] == 'e')
			e++;
	}
	while(n >= 3, i, t, e >= 3)	{
		if(e >= 3 && t >= 1 && i >= 1 && n >= 2) {
			if(counter)	{
				n -= 2;
				e-=3;
				t--;
				i--;
				counter++;
			}
			else {
				if(n >= 3) {
					n -= 3;
					e-=3;
					t--;
					i--;
					counter++;
				}
				else
					break;
			}

		}
		else
			break;
	}
	cout << counter;
	return 0;
}

#include<iostream>
#include<cstring>
using namespace std;
static const int ns = 3;
static const int is = 1;
static const int es = 3;
static const int ts = 1;
static char s[101];
int main(){
    cin.getline(s, 101);
    int n = 0, i = 0, e = 0, t = 0;
    int length = strlen(s);
    for(int k = 0; k < length; ++k)
        switch(s[k]){
            case 'n':++n; break;
            case 'i':++i; break;
            case 'e':++e; break;
            case 't':++t; break;
        }

    int m = n >= 3 ? (n - 3) / 2 + 1 : 0;
    m = min(m, i / is);
    m = min(m, e / es);
    m = min(m, t / ts);
    cout << m;

}

#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
	int i, l, sn = 0, si = 0, se = 0, st = 0, count = 0, min1 = 0,min2=0,mins;
	string str;
	string sub = "nineteenineteen";
	cin >> str;
	l = str.length();
	for (i = 0; i <l; i++)
	{
		switch (str[i])
		{
		case 'n':sn++; break;
		case 'i':si++; break;
		case 't':st++; break;
		case 'e':se++; break;
		default:break;
		}
	}
	count = (sn- 1) / 2;//count��nineteen������Ҫ
	min1 = min(count, se / 3);
	min2 = min(st, si);
	mins = min(min1, min2);
	cout << mins;
	//system("PAUSE");
	return 0;
}

#include <iostream>
#include <String>
using namespace std;

void main(){

string sentence;
char split[110];
getline(cin, sentence);
strcpy(split, sentence.c_str());

int track;
int n_count = 0;
int i_count = 0;
int e_count = 0;
int t_count = 0;
int nineteen_count = 0;

for(int i = 0; i < sentence.length(); i++){
	if(split[i] == 'n'){
		n_count++;
	}

	if(split[i] == 'i')
		i_count++;

	if(split[i] == 'e')
		e_count++;

	if(split[i] == 't')
		t_count++;
}

if(n_count >= 3 && i_count >= 1 && e_count >= 3 && t_count >= 1){
	nineteen_count++;
	n_count-= 3;
	i_count-= 1;
	e_count-= 3;
	t_count-= 1;

	while(true){

	if(n_count >= 2 && i_count >= 1 && e_count >= 3 && t_count >= 1){
		nineteen_count++;
		n_count-= 2;
		i_count-= 1;
		e_count-= 3;
		t_count-= 1;
	}

	else
		break;
}//end while

}// end if

cout << nineteen_count << endl;

} // end main

#include <bits/stdc++.h>

using namespace std;

int main()
{
    string s;
    int t,n,i,e,conte=0,contn=0,cont=0;
    t = n = i = e = 0;
    cin >> s;
    for(int ii=0;ii<s.length();ii++){
        if(s[ii]== 'i'){i++;}
        else if(s[ii]=='t'){t++;}
        else if(s[ii]=='e'){conte++;}
        else if(s[ii]=='n'){contn++;}
    }
    s="";
    while(i > 0 && t > 0 && conte >= 3 && contn >=2){
        if(cont==0){ if(contn<3){break;}s="nineteen";contn-=3;}
        else{s+="ineteen";contn-=2;}
        i--;
        t--;
        conte-=3;
        cont++;
    }
    cont=0;
    for(int ii=0;ii<s.length();ii++){
        if(ii+1!=s.length()){
            if(s[ii] == 'n' && s[ii+1] == 'i'){cont++;}
        }
    }
    cout << cont;
    return 0;
}

#include<cstdio>
#include<algorithm>
#include<climits>

using namespace std;

int a[10001],i,j,ans;
char ch;

int main()
{
	ch=getchar();
	while(ch!=-1)a[ch]++,ch=getchar();
	ans=INT_MAX;
	ans=min(ans,(a['n']-1)/2);
	ans=min(ans,a['i']);
	ans=min(ans,a['e']/3);
	ans=min(ans,a['t']);
	if(ans<0)ans=0;
	printf("%d\n",ans);
}

#include<iostream>
#include<string>
using namespace std;
int a[26];
int main()
{
    int n=0,i=0,t=0,e=0,N=0;
    string s; cin>>s;
    for(int k=0; k<s.size(); ++k)
    {
        if(s[k]=='e')++e;
        if(s[k]=='i')++i;
        if(s[k]=='t')++t;
        if(s[k]=='n')
        {
            ++n;
            if(n==3)
            {
                ++N;
                n=1;
            }
        }
    }
    e/=3;
    cout<<min(min(t,N),min(i,e));
    return 0;
}

#include <iostream>
#include <string>
using namespace std;
int main(){
 string nn="nineteen";
 string str;
 string emp="";
 cin>>str;
 int n=0;
 int i=0;
 int e=0;
 int t=0;
 for(int j=0;j<str.length();j++){
  switch(str[j]){
    case 'i': i++; break;
    case 'n': n++;break;
    case 't': t++;break;
    case 'e': e++; break;
  }
 }
 if(n>0) n--;
 n/=2;
 e/=3;
 int min=i;
 if(t<min) min=t;
 if(e<min) min=e;
 if(n<min) min=n;

 cout<<min;

    return 0;
}

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stdio.h>
#include <fstream>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#define p(x,y) pair<x,y>
#define SZ(v) (int)v.size()
#define mp(x,y) make_pair(x,y)
#define MOD 1000000007
#define MAXN 200005
#define X first
#define Y second
using namespace std;
typedef long long ll;
string s;
map<char,int> a;
int main(){
	cin>>s;
	for(int i=0;i<SZ(s);i++)
		a[s[i]]++;
	if(a['n'] == 0){cout<<0<<endl;return 0;}
	else a['n']--;
	cout<<min(min(a['n']/2,a['i']),min(a['e']/3,a['t']))<<endl;
}

#include <bits/stdc++.h>
using namespace std;
#define scin() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define FOr for(int i=n;i>=1;i--)
#define pb push_back
#define mp make_pair
#define sf scanf
#define pf printf
#define lo long long
#define lim 1000000000
#define fi first
#define spc " ";
#define endl cout<<"\n";
#define endll "\n";
#define debug "----->>"
#define se second
#define li 100005
int n,m,flag,cev,a[li],mn=lim,nn,ii,e,t;
string s;
//~ unordered_map<int,int> mpp1321;
vector<int> v;
int main(){
	cin>>s;
	for(int i=0;i<(int)s.size();i++){
		if(s[i]=='n')
			nn++;
		if(s[i]=='i')
			ii++;
		if(s[i]=='e')
			e++;
		if(s[i]=='t')
			t++;
	}
	if(nn<3){
		printf("0");
		return 0;
	}

	if(nn%3==2)
		flag=1;
	nn-=3;
	cev++;
	cev+=nn/=2;
	//~ if(flag==1)
		//~ nn++;
	e/=3;
	mn=min(cev,min(ii,min(e,t)));
	printf("%d",mn);
	return 0;
}

#include <iostream>
#include <string>
#include <map>

using namespace std;

int my_min(int a, int b)
{
    return a * (a <= b) + b * (b < a);
}

int main()
{
    string str;
    cin >> str;
    map<char, int> x;
    for (int i = 0; i < str.size(); i++)
    {
        if(x.count(str[i]))
            x[str[i]] += 1;
        else
            x[str[i]] = 1;
    }
    x['n'] -= 1;
    int i = x['i'];
    int n = x['n'] / 2;
    int t = x['t'];
    int e = x['e'] / 3;
    int result = my_min(my_min(i, n), my_min(t, e));
    cout << result;
    return 0;
}

#include <iostream>
#include <string>
using namespace std;

#define Mini(A, B) (A>B ? B : A)

int main()
{
	string s;
	cin>>s;
	int len  = s.length();
	int kN=0, kI=0, kE=0, kT=0;
	for(int i=0; i<len; i++)
	{
		if(s[i]=='n')
		{
			kN++;
		}
		else if(s[i]=='i')
		{
			kI++;
		}
		else if(s[i]=='e')
		{
			kE++;
		}
		else if(s[i]=='t')
		{
			kT++;
		}
	}
	int kol=0;
	//cout<<kN<<" "<<kI<<" "<<kE<<" "<<kT<<endl;
	if(kN<3 || kI<1 || kE<3 || kT<1)
	{
		cout<<0<<endl;
		return 0;
	}
	else
	{
		kN-=3;
		kI--;
		kE-=3;
		kT--;
	}
	kN/=2;
	kE/=3;
	//cout<<kN<<" "<<kI<<" "<<kE<<" "<<kT<<endl;
	kol=Mini(Mini(kN, kI),Mini(kE, kT));
	//cout<<kol<<endl;
	cout<<(kol+=1)<<endl;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
int main()
{
  char c;
  int n=0,i=0,t=0,e=0;
  while (cin>>c)
  {
    if (c=='n')
    {
      n++;
    }
    else if (c=='i')
    {
      i++;
    }
    else if (c=='t')
    {
      t++;
    }
    else if (c=='e')
    {
      e++;
    }
  }
  int cont =0;
  for (int k=i;k>0;k--)
  {
    if (n>=2*k+1 && t>=k && e>=3*k)
    {
      cont++;
    }
  }
cout<<cont<<endl;
return 0;
}
// 1512763140366

#include<bits/stdc++.h>
using namespace std;
char s[105];
int n,i,e,t;//nineteen的字母
int main()
{
    scanf("%s",s+1);
    int len=strlen(s+1);
    for(int w=1;w<=len;w++)
    {
        if(s[w]=='n') n++;
        if(s[w]=='i') i++;
        if(s[w]=='e') e++;
        if(s[w]=='t') t++;
    }
    printf("%d\n",min(min(min(t,i),e/3),(n-1)/2));//3个n,1个i,3个e,1个t
    return 0;
}

#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;
int main() {
	 string s;
	 cin >> s;
	 int n=0,i=0,e=0,t=0; //nineteen
	 for(int j=0;j<s.size();j++)
		if		(s[j] == 'n') n++;
		else if (s[j] == 'i') i++;
		else if (s[j] == 'e') e++;
		else if (s[j] == 't') t++;
	n--;
	int m = min(min(n/2,i),min(e/3,t));
	cout << m;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;

int main()
{
    long counter=0;
string str;
cin>>str;
char arr[]={'n','i','t','e'};
int arr_counter[4]={0};
for(int i=0;i<str.size();i++){
         // char c=(char)str[i];
    for(int j=0;j<4;j++){
      if(str[i]==arr[j])
        arr_counter[j]++;

    }
}
//for(int j=0;j<4;j++)
//   cout<<arr_counter[j]<<" ";
        if(arr_counter[0]>=3&&arr_counter[3]>=3&&arr_counter[1]>=1&&arr_counter[2]>=1){
              for(int i=0;;i++){
                    arr_counter[0]-=3;
                    arr_counter[1]--;
                    arr_counter[2]--;
                    arr_counter[3]-=3;
                    counter++;
                   arr_counter[0]++;
             if(arr_counter[0]<3||arr_counter[1]<1||arr_counter[2]<1||arr_counter[3]<3)
                break;

              }
              cout<<counter;

        }
        else
            cout<<counter;

    return 0;
}

#include <bits/stdc++.h>
using namespace std;

int main()
{
    long counter=0;
string str;
cin>>str;
char arr[]={'n','i','t','e'};
int arr_counter[4]={0};
for(int i=0;i<str.size();i++){
         // char c=(char)str[i];
    for(int j=0;j<4;j++){
      if(str[i]==arr[j])
        arr_counter[j]++;

    }
}
//for(int j=0;j<4;j++)
//   cout<<arr_counter[j]<<" ";
        if(arr_counter[0]>=3&&arr_counter[3]>=3&&arr_counter[1]>=1&&arr_counter[2]>=1){
              for(int i=0;;i++){
                    arr_counter[0]-=2;
                    arr_counter[1]--;
                    arr_counter[2]--;
                    arr_counter[3]-=3;
                    counter++;
                  // arr_counter[0]++;
             if(arr_counter[0]<3||arr_counter[1]<1||arr_counter[2]<1||arr_counter[3]<3)
                break;

              }
              cout<<counter;

        }
        else
            cout<<counter;

    return 0;
}

#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long int ll;
void solve()
{
    string s;
    cin>>s;
    int n=0,i=0,t=0,e=0,j,count=0;
    for(j=0;s[j]!='\0';j++)
    {
        if(s[j]=='n')
        n++;
         if(s[j]=='i')
         i++;
        if(s[j]=='t')
            t++;
        if(s[j]=='e')
            e++;
    }
   // cout<<n<<i<<t<<e;
   // if(n-2>0&&t>0&&i>0&&e>1){
    while(n-3>=0&&i-1>=0&&t-1>=0&&e-3>=0)
    {
        n=n-3;
        t=t-1;
        e=e-3;
        i=i-1;
        n=n+1;
        count++;
    //}
    }
    cout<<count<<"\n";
}
int main()
{
      ios::sync_with_stdio(false);
      cin.tie(NULL);
      cout.tie(NULL);
    //  int t;
     // cin>>t;
     // while(t--)
      //{
            solve();
      //}
      return 0;
}

#include<stdio.h>
#include<iostream>
#include<string>
using namespace std;

int main()
{

	string str, str2;

    cin >> str;

		int i_num = 0;
		int t_num = 0;
		int n_num = 0;
		int e_num = 0;

		for (int i = 0; i < strlen(str.c_str()); i++)
		{
			if (str[i] == 'i')
			{
				i_num = i_num + 1;
			}
			else if (str[i] == 't')
			{
				t_num = t_num + 1;
			}
			else if (str[i] == 'n')
			{
				n_num = n_num + 1;
			}
			else if (str[i] == 'e')
			{
				e_num = e_num + 1;
			}
		}

		int g_num = i_num < t_num ? i_num : t_num;

		int s_num = (n_num - 1) / 2 < e_num / 3 ? (n_num - 1) / 2 : e_num / 3;

		int t_sum = g_num < s_num ? g_num : s_num;

		cout << t_sum;

	return 0;
}

#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define all(x)              (x).begin(), (x).end()
#define inf                 1e18
#define PI                  -2 * atan2(-1, 0)

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
//    ifstream cin("input.txt");
//    ofstream cout("output.txt");
    string s;
    cin >> s;
    map <char, int> mp;
    for (auto i : s)
        ++mp[i];
    cout << min({mp['i'], mp['t'], mp['e'] / 3, (mp['n'] - 1) / 2});
}

#include<iostream>
#include<fstream>

using namespace std;

int main()
{    string s;
    int a=0, b=0, c=0, d=0, nr=0;

    cin>>s;
    for(int i=0; i<s.size(); i++)
    {   if(s[i]=='n') a++;
        else if(s[i]=='i') b++;
        else if(s[i]=='e') c++;
        else if(s[i]=='t') d++;
    }

   // cout<<a<<"\n"<<b<<"\n"<<c<<"\n"<<d<<"\n";
while(a>=3 and b>=1 and c>=3 and d>=1)
    { nr++; a-=2; b-=1; c-=3; d-=1;
    if(a<3 or b<1 or c<3 or d<1) break;

    }

    cout<<nr;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;

int main()
{
	string str;

	cin >> str;

	int n, i, e, t;

	n = i = e = t = 0;

	for(int k = 0; str[k]; k++)
	{
		if(str[k] == 'n') n++;
		if(str[k] == 'i') i++;
		if(str[k] == 'e') e++;
		if(str[k] == 't') t++;
	}
	e/=3;
	n=max(0, n-1)/2;
	cout<<min(min(n, i), min(e, t))<<endl;
}

/*
nniinneetteeeenn

nneteenabcnneteenabcnneteenabcnneteenabcnneteenabcii

nineteenineteen
*/

// 1502225081550

#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int cntn=0,cnte=0,cnti=0,cntt=0,ans=0,ans1,ans2=0;
    //nineteen
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='n')
        {
            cntn++;
        }
        if(s[i]=='e')
        {
            cnte++;
        }
        if(s[i]=='i')
        {
            cnti++;
        }
        if(s[i]=='t')
        {
            cntt++;
        }
    }
//    cout<<cntn<<" "<<cnte<<" "<<cnti<<" "<<cntt<<endl;
    cnte=cnte/3;
    cntn=(cntn-1)/2;
    ans=min(cnte,cntn);
    ans1=min(cnti,cntt);
    ans2=min(ans,ans1);
    cout<<ans2<<endl;
}

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>
using namespace std;

typedef long long int LL;
typedef pair<int,int> PII;

int main(int argc, char*argv[]) {
    ios_base::sync_with_stdio(false);
    int r=0, size, size2;
    string s, g;
    cin >> s;
    size = s.size();

    g = "nineteen";
    size2 = g.size();
    map<char, int> cnt_goal;
    for (int i = 0; i < size2; ++i)
        cnt_goal[g[i]]++;
    cnt_goal[g[0]]--;

    map<char, int> cnt;
    for (int i = 0; i < size; ++i)
        cnt[s[i]]++;

    r = 10000;
    for (const auto it : cnt_goal)
        r = min(r, cnt[it.first]/it.second);
    if (cnt[g[0]] <= r*cnt_goal[g[0]])
        r = max(r-1, 0);

    cout << r << endl;
    return EXIT_SUCCESS;
}

#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <ctime>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iostream>
#include <algorithm>
using namespace std;
#define FOR(i,a,b) for(int _b=(b),i=(a); i<_b; ++i)
#define ROF(i,b,a) for(int _a=(a),i=(b); i>_a; --i)
#define _1 first
#define _2 second
#define PB(x) push_back(x)
#define MP(x,y) make_pair(x,y)
#define MSET(m,v) memset(m,v,sizeof(m))
#define MAX_PQ(T) priority_queue <T>
#define MIN_PQ(T) priority_queue <T,vector<T>,greater<T>>
typedef long long LL; typedef long double LD; typedef unsigned int uint;
typedef pair<int,int> PII; typedef pair<LL,LL> PLL;
typedef vector<int> VI; typedef vector<LL> VL; typedef vector<PII> VP;
template<typename A, typename B> inline bool mina(A &x, B y) { return (x > y)? (x=y,1):0; }
template<typename A, typename B> inline bool maxa(A &x, B y) { return (x < y)? (x=y,1):0; }

// More templates here

string N = "nineteen";
string S;
int C[128];
int D[128];

void f(string s, int *a)
{
	for(char c: s) ++a[int(c)];
}

int main()
{
	cin >> S;
	f(S, C);
	f(N, D);

	--D['n'];
	--C['n'];

	int sol = 100;
	FOR(i,0,128) if(D[i]) mina(sol, C[i] / D[i]);
	cout << sol << endl;

	return 0;
}

#include<bits/stdc++.h>
#include<math.h>
using namespace std;
/*int minimum(int n,int i, int e,int t)
{
    int a=n<i?n:i;
    int b=e<t?e:t;
    return ((a<b)?a:b);
}*/
int main()
{
    string s;
    const int divn=3, dive=3, divi=1, divt=1;
    int n=0,i=0,e=0,t=0;
    cin>>s;
    for(int j=0;j<s.size();j++)
    {
        if(s[j]=='n')
        {
            ++n;
            //break;
        }
        else if(s[j]=='i')
        {
            ++i;
            //break;
        }
        else if(s[j]=='e')
        {
            ++e;
            //break;
        }
        else if(s[j]=='t')
        {
            ++t;
            //break;
        }
    }
    int min = e/dive;
    if(i/divi < min){min = i/divi;}
    if(t/divt < min){min = t/divt;}
    if((n - 1)/(divn - 1) < min){min = (n - 1)/(divn - 1);}
    cout<<min<<endl;
    return 0;
}

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <map>

using namespace std;

int main() {
	int cnt = 0;
	map<char,int> m;
	string ss;
	cin >> ss;
	for (int i = 0; i < ss.length(); i++) {
		m[ss[i]]++;
	}
	vector<int> vec;
	vec.push_back((m['n']-1)/2);
	vec.push_back(m['e']/3);
	vec.push_back(m['i']/1);
	vec.push_back(m['t']/1);
	sort(vec.begin(),vec.end());
	cout << vec[0] << endl;
}

    #include<bits/stdc++.h>
    using namespace std;
    int i=0,a[1000010];
    string s;
    int main()
    {
        for(cin>>s;i<s.size();i++)
            a[s[i]]++;
        cout<<min((a['n']-1)/2,min(a['e']/3,min(a['t'],a['i'])))<<endl;
    }

#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif
#include <iostream>
#include <cmath>
#include <iomanip>
#include <string>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <stdio.h>
#include <climits>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <sstream>
#include <map>
#include <ctime>
#include <cstdlib>
#include <list>
#include <bitset>
#include <functional>
#include <numeric>
#include <utility>
#include <array>

using namespace std ;

void Hima(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}

int main ()
{
    Hima();
    string s;
    cin>>s;
    int n=0,i=0,t=0,e=0,c=0;
    int sz=s.size();
    for(int j=0;j<sz;j++)
    {

        if(s[j]=='n')
            { n++;
        //if(j>2&&s[j-1]=='e'&&s[j+1]=='i') n++;
        }
        else if(s[j]=='i') i++;
        else if(s[j]=='t') t++;
        else if(s[j]=='e') e++;
    }
    //cout<<n<<" "<<e<<" "<<i<<" "<<t<<endl;
    //--------------------------------

    if(n>3&&n%2==1)
    {
        int y=n/2;
        n=y*3;
    }
    else if(n>3)
    { n--;
     int y=n/2;
        n=y*3;
    } bool v=1;
    //cout<<n<<" "<<e<<" "<<i<<" "<<t<<endl;
    while(i>=1&&t>=1&&n>=3&&e>=3)
    {
        n-=3;
        e-=3;
        i--;
        t--;
        c++;
    }

    cout<<c<<endl;
    return 0;
}

/*
if(n>=5&&n%3!=0)
     {n++;
         while(n%3!=0&&n>=5) n++;
    }
    cout<<n<<" "<<e<<" "<<i<<" "<<t<<endl;
    while(i>=1&&t>=1&&n>=3&&e>=3)
    {
        n-=3;
        e-=3;
        i--;
        t--;
        c++;
    }

    cout<<c<<endl;
*/

#include <iostream>
#include <cmath>
#include <set>
#include <string>
#include <cstring>
using namespace std;

int gn(char x) {
    return x - int('a');
}

int main() {
    string s;
    cin >> s;
    int n[26] = {0};
    for(int i = 0; i < s.length(); i++) {
            n[s[i] - int('a')]++;
    }
    int ans = 0;
    n[gn('n')]--;
    while(n[gn('n')] >= 2 && n[gn('i')] >= 1 && n[gn('e')] >= 3 && n[gn('t')] >= 1) {
                     ans++;
                     n[gn('n')] -= 2;
                     n[gn('i')] -= 1;
                     n[gn('e')] -= 3;
                     n[gn('t')] -= 1;
    }
    cout << ans;
    return 0;
}

#include <iostream>
#include <map>

using namespace std;

int main()
{
    int r = 0;
    string s, n = "neetenin";
    bool c, pri = true;

    cin >> s;

    map < char, int > mapa;

    for(char i:s)
        mapa[i]++;

    while(true)
    {
        c = true;

        for(char i:n)
        {
            if(mapa[i] > 0)
                mapa[i]--;
            else
                c = false;
        }

        if(pri)
            n.erase(n.end() - 1);

        if(!c)
            break;
        else
            r++;

        pri = false;
    }

    cout << r << "\n";

	return 0;
}

#include <bits/stdc++.h>
#define Sort(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
using namespace std;

typedef long long int64;
typedef pair<int,int> pii;

inline int64 gcd(int64 a, int64 b) {return __gcd(a,b);};
inline int64 lcm(int64 a, int64 b) {return a*b/gcd(a,b);};

int main() {
	ios_base::sync_with_stdio(0);

	string S;
	cin>>S;
	int n = 0; // 3
	int i = 0; // 1
	int e = 0; // 3
	int t = 0; // 1
	for(int j = 0; j < S.size(); j++) {
		if(S[j] == 'n') n++;
		if(S[j] == 'i') i++;
		if(S[j] == 'e') e++;
		if(S[j] == 't') t++;
	}
	int res;
	if(n > 3)
		 res = min((n-1)/2, min(i/1,min(e/3,t/1)));
	else
		res = min(n/3, min(i/1,min(e/3,t/1)));

	cout<<res<<endl;

}

#include<iostream>
#include<cstring>
using namespace std;
const int N=1000;
char a[N];
int main()
{
    while(cin>>a)
    {
        int n=0,i=0,t=0,e=0,h;
        for (int j=0;j<100;j++){
            if (a[j]=='n') n++;
            else if (a[j]=='i') i++;
            else if (a[j]=='t') t++;
            else if (a[j]=='e') e++;
        }
        int x=n,flag=0;
         e/=3; n/=3;
        while(flag!=2){
            h=n;
            if (h>i) h=i;
            if (h>t) h=t;
            if (h>e) h=e;
            if (!h) break;
            if (h==1) {
                if ((x+1)/3<=n)  break;
                else { n=(x+1)/3; flag++; continue;}
            }
            if (h==2){
                if ((x+2)/3<=n) break;
                else { n=(x+2)/3 ; flag++; continue;}
            }
            if (h>2){
                if ((2+(h-2)*2+x)/3<=n) break;
                else { n=(2+(h-2)*2+x)/3; flag++; continue;}
            }
        }
        cout<<h<<endl;
        memset(a,0,sizeof(a));
    }
}

#include<iostream>
#include<set>
#include<cstdio>
using namespace std;
int main(){
	string str;
	int s1=0,s2=0,s3=0,s4=0;
	cin>>str;
	int n=str.size();
	for(int i=0;i<n;i++){
	    if(str[i]=='n')	s1++;
	    else if(str[i]=='i') s2++;
	    else if(str[i]=='e') s3++;
	    else if(str[i]=='t') s4++;
	}
	//cout<<s1<<" "<<s2<<" "<<s3<<" "<<s4<<endl;
	s1--;
	s1=s1/2;
	s3=s3/3;
    printf("%d\n",min(s1,min(s2,min(s3,s4))));
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long int lln;
#define all(x) x.begin(),x.end()
#define pb push_back

int main() {
	// your code goes here
	 // For getting input from input.txt file
   // freopen("input.txt", "r", stdin);

    // Printing the Output to output.txt file
   // freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie();
   int t=1;
   while(t--){
	string s;
	cin>>s;
	int x,y,a[26]={};
	for(int i=0;i<s.size();i++)
	{
	    a[s[i]-97]++;
	}

   if(a[13]>4 && a[13]%2!=0)x=min((a[13])/2,a[4]/3);
    else if(a[13]>4 && a[13]%2==0)x=min((a[13]-1)/2,a[4]/3);
   else
    x=min((a[13])/3,a[4]/3);
    y=min(a[8]/1,a[19]/1);
    cout<<min(x,y);

   }
	return 0;
}

#include <iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  string st;
  cin >> st;
  vector<int> vec;
  vec.push_back( count(st.begin(), st.end(), 'i'));
  vec.push_back( count(st.begin(), st.end(), 'e')/3);
  int n= count(st.begin(), st.end(), 'n');
  if(n<3){
    vec.push_back(0);
  }else{
    vec.push_back(1+ (count(st.begin(), st.end(), 'n')-3 )/2   );
  }
  vec.push_back(count(st.begin(), st.end(), 't') );
  int ing= *min_element(vec.begin(), vec.end());
  cout << ing<< endl;
  return 0;

}

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
using namespace std;
#define pb push_back;
#define po(x) 1<<x
#define schnell ios_base::sync_with_stdio(NULL); cin.tie(NULL); cout.tie(NULL)
typedef long long ll;
typedef long double ld;
#define DIM 10007
#define DIM2 10007
#define MODULO 998244353
const ll mask = po(9)-1;
struct pp {
	ll fi, sc;
	bool operator < (const pp b) {
		if (fi == b.fi)return sc < b.sc;
		return fi < b.fi;
	}
	bool operator > (const pp b) {
		if (fi == b.fi)return sc > b.sc;
		return fi > b.fi;
	}
	bool operator == (const pp b) {
		if (fi == b.fi && sc == b.sc)return 1;
		return 0;
	}
};
string s;
ll resi, resn, rese, rest;
int main() {
	schnell;
	cin >> s;
	for (ll i = 0; i < s.length(); i++) {
		if (s[i] == 'n')resn++;
		if (s[i] == 'e')rese++;
		if (s[i] == 't')rest++;
		if (s[i] == 'i')resi++;
	}
	ll res = 0;
	if (resn >= 3 && rese >= 3 && rest >= 1 && resi >= 1) {
		resn -= 3; rese -= 3; rest--; resi--;
		res++;
		resn /= 2; rese /= 3;
		cout << 1 + min(min(resn, rese), min(resi, rest)) << endl;
	}
	else {
		cout << 0 << endl;
	}
}

#include <iostream>
#include <map>
#include <utility>

using namespace std;

int minimum(map<char, int> mapper) {
    int n = mapper['n'], mini = -1;
    mapper['e'] /= 3;
    n = (n % 2 == 0) ? (n / 2 - 1) : n / 2;
    mapper['n'] = (n < 0) ? 0 : n;
    for (map<char, int>::iterator iterator1 = mapper.begin(); iterator1 != mapper.end(); ++iterator1) {
        mini = (mini == -1) ? iterator1->second : (iterator1->second < mini) ? iterator1->second : mini;
    }
    cout << endl;
    return mini;
}

int main() {
    map<char, int> mapper;

    string ch;
    cin >> ch;
    mapper['e'] = mapper['t'] = mapper['n'] = mapper['i'] = 0;
    for (int i = 0; i < ch.length(); i++) {
        if (ch[i] == 'n' || ch[i] == 'i' || ch[i] == 'e' || ch[i] == 't')
            mapper[ch[i]]++;
    }

    cout << minimum(mapper);
    return 0;
}

#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
string s;
int n, i, e, t;
int main()
{
    getline(cin,s);
    for(int j = 0;j < s.size();j++)
        switch(s[j])
        {
            case 'n':n++;break;
            case 'i':i++;break;
            case 'e':e++;break;
            case 't':t++;break;
        }
    cout << min((int)(e/3),min((int)((n-1)/2),min(i,t)));
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int i,a[9999999]; char s[9999999];
int main()
{
    for (cin>>s;i<strlen(s);i++) a[s[i]]++;
    printf("%d",min((a['n']-1)/2,min(a['e']/3,min(a['t'],a['i']))));
}

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main() {

    string s;
    cin >> s;

    vector<int> freq(26, 0);
    for (size_t i = 0; i < s.length(); i++) {
        freq[s[i]-'a']++;
    }

    vector<int> freq19(26, 0);
    for (size_t i = 0; i < string("nineteen").length(); i++) {
        freq19[string("nineteen")[i]-'a']++;
    }

    int nn;
    if (freq['n'-'a'] < 3) {
        nn = 0;
    } else {
        nn = (freq['n'-'a']-1) / 2;
    }
    int ii = freq['i'-'a'] / 1;
    int ee = freq['e'-'a'] / 3;
    int tt = freq['t'-'a'] / 1;

    int ans = min(min(nn, ee), min(ii, tt));
    cout << ans << endl;

    return 0;
}

#include <stdio.h>

int min(int a, int b)
{
	if (a < b)
		return a;
	else
		return b;
}

int main(void)
{
	char c;
	int n = 0, t = 0, e = 0, i = 0;

	while (scanf("%c", &c) && c != '\n')
	{
		if (c == 'n')
			n++;
		else
		if (c == 'e')
			e++;
		else
		if (c == 't')
			t++;
		else
		if (c == 'i')
			i++;
	}
	--n;
	n /= 2;
	e /= 3;

	printf("%d\n", min(min(n, t), min(e, i)));
	return 0;
}

//#include <fsociety>
#include <bits/stdc++.h>
using namespace std;
map <char,int> mp;
int ans;
string s;
int main(){
	cin>>s;
	for(int i = 0 ; i<s.size() ; i++){
		if (s[i]=='n') mp['n']++;
		if (s[i]=='i') mp['I']++;
		if (s[i]=='e') mp['e']++;
		if (s[i]=='t') mp['t']++;

	}
ans=min(mp['I'],min((mp['n']-1)/2,min(mp['e']/3,mp['t'])));
cout<<ans;
}

#include <bits/stdc++.h>
using namespace std;
char s[105];
int n,i,e,t,len;
int main()
{
	scanf("%s",s+1);
	len=strlen(s+1);
	for(int w=1;w<=len;w++)
	{
		if(s[w]=='n') n++;
		if(s[w]=='i') i++;
		if(s[w]=='e') e++;
		if(s[w]=='t') t++;
	}
	cout<<min(min(min(t,i),e/3),(n-1)/2);
	return 0;
}

#include<stdio.h>
#include<string.h>
#include<string>
#include<algorithm>
using namespace std;
char s[110];
int d[4],ans;
int main()
{
    memset(d,0,sizeof(d));
    scanf("%s",s);
    int len = strlen(s);
    for(int i = 0; i < len; i++)
    {
        if(s[i] == 'n')
        {
            d[0]++;
        }
        else if(s[i] == 'i')
        {
            d[1]++;
        }
        else if(s[i] == 't')
        {
            d[2]++;
        }
        else if(s[i] == 'e')
        {
            d[3]++;
        }
    }
    int m = d[0];
    while(m > 0)
    {
        d[0] += m / 3;
        m /= 3;
    }
    ans = 100;
    ans = ans < d[0] / 3 ? ans : d[0] / 3;
    ans = ans < d[1] ? ans : d[1];
    ans = ans < d[2] ? ans : d[2];
    ans = ans < d[3] / 3 ? ans : d[3] / 3;
    printf("%d\n",ans);
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
char s[105];
int n,i,e,t;
int main()
{
    cin>>s+1;
    int len=strlen(s+1);
    for(int w=1;w<=len;w++)
    {
        if(s[w]=='n') n++;
        if(s[w]=='i') i++;
        if(s[w]=='e') e++;
        if(s[w]=='t') t++;
    }
   cout<<min(min(min(t,i),e/3),(n-1)/2);
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
char a[105];int an,ai,ae,at,l,i;
int main(){
	scanf("%s",a);
	l=strlen(a);
	for(i=0;i<l;i++){
		if(a[i]=='n') an++;
		if(a[i]=='i') ai++;
		if(a[i]=='e') ae++;
		if(a[i]=='t') at++;
	}
	printf("%d",min((an-1)/2,min(ai,min(ae/3,at))));
	return 0;
}

#include<iostream>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{//for(;;){
    string s;
    cin>>s;
    long long a=0,b=0,c=0,d=0;
    for(int i=0;i<(int)s.length();i++)
    {
        if(s[i]!='n'&&s[i]!='i'&&s[i]!='e'&&s[i]!='t')
            continue;
        else
        {
            if(s[i]=='n')
                a++;
            else if(s[i]=='i')
               b++;
            else if(s[i]=='e')
                c++;
            else if(s[i]=='t')
                d++;
        }
    }
    if(b&&d&&a&&c)
    {
        if(min(a,c)>=3*min(b,d))
            cout<<min(b,d)<<endl;
        else if(a==min(a,c))
        {
            if(a==c)
                cout<<a/3<<endl;
            else
            {

 a--;
                cout<<a/2<<endl;
            }
        }
        else
            cout<<min(a,c)/3<<endl;
    }
    else
        cout<<0<<endl;//}
return 0;
}

#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
using namespace std;

int main() {
    string input;
    cin >> input;
    vector<int> totals;
    map<char,int> letters;
    letters['n'] = 3;
    letters['i'] = 1;
    letters['e'] = 3;
    letters['t'] = 1;

    for_each(letters.begin(),letters.end(),[&] (std::pair<char,int> a) {
        int count = std::count(input.begin(),input.end(),a.first);
        if(a.first == 'n' && count >= 3) {
            totals.push_back(1+(count - 3)/2);
        } else {
            totals.push_back(count/a.second);
        }
    });
    std::cout << *min_element(totals.begin(),totals.end()) << std::endl;

}

#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<algorithm>
char a[300];
int n,i,e,t;
inline int Imin(int x,int y)
{
	return x<y?x:y;
}
int main()
{
	scanf("%s",a+1);
	for(int j=1;a[j];j++)
	{
		if(a[j]=='n') n++;
		if(a[j]=='i') i++;
		if(a[j]=='e') e++;
		if(a[j]=='t') t++;
	}
	printf("%d\n",Imin(Imin((n-1)/2,e/3),Imin(i,t)));
	return 0;
}

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<string>
#include<cstdlib>
using namespace std;
string a;
int ans[123];
int main(){
	cin>>a;
	for(int i=0;i<a.length();i++) ans[a[i]]++;
	cout<<min((ans['n']-1)/2,min(ans['e']/3,min(ans['i'],ans['t'])));
 	return 0;
}

#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int p=s.length();
    int count_n=0;
    int count_e=0;
    int count_t=0;
    int count_i=0;
    int ans=0;
    for(int i=0;i<p;i++)
    {
        if(s[i]=='n'||s[i]=='N')
        count_n++;
        if(s[i]=='I'||s[i]=='i')
        count_i++;
        if(s[i]=='T'||s[i]=='t')
        count_t++;
        if(s[i]=='e'||s[i]=='E')
        count_e++;

    }
   ans=min(min(min((count_n-1)/2, count_i), count_e/3), count_t);
    cout<<ans<<endl;
    return 0;

}

#define _CRT_SECURE_NO_DEPRECATE
#include<iostream>
#include<algorithm>
#include<cstring>
#include<sstream>
#include<string>
#include<map>
#include<vector>
using namespace std;
int t, n;
int a[4];
int main()
{
	//freopen("C:\\Users\\Shinelon\\Desktop\\对拍\\1.txt", "r", stdin);
	//freopen("C:\\Users\\Shinelon\\Desktop\\对拍\\2.txt", "w", stdout);
	char c[105];
	cin >> c;

	for(int i=0;i<strlen(c);i++)
	{
		if (c[i] == 'n') a[0]++;
		if (c[i] == 'i') a[1]++;
		if (c[i] == 'e') a[2]++;
		if (c[i] == 't') a[3]++;
	}
	a[2] /= 3;
	if (a[0] >= 3) a[0] = (a[0] - 3) / 2 + 1;
	else a[0] = 0;
	sort(a, a + 4);
	cout << a[0] << endl;

	//system("pause");
	return 0;
}

#include <bits/stdc++.h>
#define min(a,b) (a < b ? a : b)
using namespace std;
map <char,int> ans;
char c;
int main()
{
	while (cin >> c)
	  ans[c]++;
	cout << min(min(min((ans['n'] - 1) / 2,ans['e'] / 3),ans['i']),ans['t']);
	return 0;
}

#include <iostream>

using namespace std;

int main() {

    string nineteen;

    cin >> nineteen;

    int n, e, i, t;

    n = e = i = t = 0;

    for (int k = 0; k < nineteen.length(); k++) {
        if (nineteen[k] == 'n') {
            n++;
        } else if (nineteen[k] == 'i') {
            i++;
        } else if (nineteen[k] == 'e') {
            e++;
        } else if (nineteen[k] == 't') {
            t++;
        }
    }

    int character = 0;
    int it = 0;
    int words = 0;

    while (1) {

        if (n >=  2) {
            if (it == 0) {
                n -= 3;
                if (n < 0) {
                    break;
                }
                character += 3;
            } else {
                n -= 2;
                character += 3;
            }

        } else {
             break;
        }

        it++;

        if (e >= 3) {
            e -= 3;
            character += 3;
        } else {
            break;
        }

        if (i >= 1) {
            i -= 1;
            character += 1;
        } else {
            break;
        }

        if (t >= 1) {
            t -= 1;
            character += 1;
        } else {
            break;
        }

        words++;
        character = 0;

    }
    cout << words << endl;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;int i=0,a[1000010];string s;int main()
{
    for(cin>>s;i<s.size();i++)
    {
    a[s[i]]++;
    }
    //cout<<a['n']<<" "<<a['e']<<endl;
    cout<<min((a['n']-1)/2,min(a['e']/3,min(a['t'],a['i'])))<<endl;

}

#include<bits/stdc++.h>
using namespace std;
int ma(int _a,int _b){if(_a<_b) return _a;return _b;}
int main()
{
	string s;
	cin>>s;
	int num=s.length(),n=0,i=0,e=0,t=0;
	for(int j=0;j<num;j++)
	{
		if(s[j]=='n') n++;
		else if(s[j]=='i') i++;
		else if(s[j]=='e') e++;
		else if(s[j]=='t') t++;
	}
	if(n<3)  printf("0");
	else printf("%d",ma((n+1)/2-1,ma(i,ma(t,e/3))));
	return 0;
}

#include<iostream>
#include<string>
#include<cmath>
using namespace std;
int main()
{

string s;
cin>>s;

int n1=0,i1=0,e1=0,t1=0;
for (int i=0;s[i]!='\0';i++)
{

	switch(s[i])
	{
	case 'n'	: n1++;
	break;

	case 'i'	: i1++;
	break;

	case 'e'	: e1++;
	break;

	case 't'	: t1++;
	break;

	}

}

int d1,d2,low;
n1=(n1-1)/2;
e1=e1/3;
if (n1>e1)
d1=e1;
else d1=n1;

if (i1>t1)
d2=t1;
else d2=i1;

if (d1>d2)
low=d2;
else low = d1;

cout<<low;

}

#include<cstdio>
#include<cstring>
#include<algorithm>

class Solution{
private :
	static const int maxn = 207;
    int len, tot[maxn];
    char s[maxn];

public :
    Solution() {
        Get();
        Solve();
    }

    void Get() {
    	scanf("%s", s);
        //n = "nineteen";
    }

    void Solve() {
    	len = strlen(s);
        for (register int i = 0; i < len; i++) {
        	tot[s[i]]++;
        }
        printf("%d\n", std :: min((tot['n'] - 1) / 2, std :: min(tot['e'] / 3, std :: min(tot['i'], tot['t']))));
    }
};
Solution sol;

int main() {}

#include<bits/stdc++.h>
using namespace std;
int main(){
    int i;
  string s;
  int size;
  cin>>s;
  size = s.size();
  map<char,int> count;
  count['i'] = 0;
  count['e'] = 0;
  count['t'] = 0;
    count['n'] = 0;

  for(i=0; i<size; i++){
      if(s[i]=='n'){
          count['n']++;
      }else{
          if(s[i]=='i'){
             count['i']++;
          }else{
              if(s[i]=='e'){
                 count['e']++;
              }else{
                  count['t']++;
              }
          }
      }
  }
    //count['n'] = count['n']/3;
    count['e'] = count['e']/3;
   map<char,int>:: iterator it;
   size = count['e'];
   for(it=count.begin(); it!=count.end(); it++){
       if(it->first != 'n'){
       if(size>it->second){
           size = it->second;
       }
       }
   }
   if(size){
   while(count['n']<(3*size-(size-1))){
       size--;
   }
   }
       cout<<size;

}

#include <iostream>
#include <string>
using namespace std;
int main()
{
	string s;
	cin >> s;
	int x = 0;
	for (int i = 0; i < s.size(); i++)
	{
		string s2 = s;
		for (int z = 0; z < s.size(); z++)
		{
			s2[z] = ' ';
		}
		if (s[i] == 'n')
		{
			swap(s[i], s2[i]);
			for (int j = 0; j < s.size(); j++)
			{
				if (s[j] == 'i')
				{
					swap(s[j], s2[j]);
					for (int k = 0; k < s.size(); k++)
					{
						if (s[k] == 'n')
						{
							swap(s[k], s2[k]);
							for (int l = 0; l < s.size(); l++)
							{
								if (s[l] == 'e')
								{
									swap(s[l], s2[l]);
									for (int m = 0; m < s.size(); m++)
									{
										if (s[m] == 't')
										{
											swap(s[m], s2[m]);
											for (int n = 0; n < s.size(); n++)
											{
												if (s[n] == 'e')
												{
													swap(s[n], s2[n]);
													for (int b = 0; b < s.size(); b++)
													{
														if (s[b] == 'e')
														{
															swap(s[b], s2[b]);
															for (int v = 0; v < s.size(); v++)
															{
																if (s[v] == 'n')
																{

																	x++;
																	v = s.size();
																	b = s.size();
																	n = s.size();
																	m = s.size();
																	l = s.size();
																	k = s.size();
																	j = s.size();

																}
															}
														}
													}
												}
											}
										}
									}
								}
							}
						}
					}
				}
			}
		}
		}
	cout << x << endl;
}

#include <cstdio>
#include <iostream>
#include <string>
using namespace std;
int t[10];
string s, p = "nineteen";
int main() {
	cin >> s;
	for (int i = 0; i < s.length(); ++i) {
		if (s[i] == 'n') ++t[1];
		else if (s[i] == 'i') ++t[2];
		else if (s[i] == 'e') ++t[3];
		else if (s[i] == 't') ++t[4];
	}
	--t[1];
	t[1] /= 2;
	t[3] /= 3;
	for (int i = 2; i <= 4; ++i)
		t[1] = min(t[1], t[i]);
	printf("%d", t[1]);
	return 0;
}

/*
=================
Date : 3-08-2020
Author : Aman Jain
=================
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

using namespace __gnu_pbds;
using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for (int i=0; i < n; i++)
#define REPX(a, n) for (int j=a; i < n; j++)
#define MAX_STRING_LENGTH 100
#define ll long long
#define ull unsigned long long
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define Itr(it,a) for(auto it = a.begin(); it != a.end(); it++)
#define ok order_of_key
#define fo find_by_order
#define sortA(a,n) sort(arr,arr+n)
#define sortV(v)  sort(v.begin(),v.end())
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
typedef map<int,int> mii;
typedef map<string,int>msi;
typedef map<char,int>mci;
typedef map<ll,ll>mll;
typedef priority_queue<int,vector<int>,greater<int>> MinPq;
typedef priority_queue<int> MaxPq;
typedef unordered_set<int> unset;
typedef unordered_set<ll> unsetll;
typedef unordered_map<int,int> unmap;
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update> pbds;
const char nl ='\n';
//const long long MOD = 1e9 + 7;
const long long INF = 1e9 + 7;

int div_ceil(int numerator, int denominator)
{
        std::div_t res = std::div(numerator, denominator);
        return res.rem ? (res.quot + 1) : res.quot;
}

void IO() {

    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

}

// ============= CODE =============

void decode(){
    string str;
    map<char,int> mp;
    cin>>str;
    for(int i=0; i<str.length() ; i++){
        if(str[i]=='n' || str[i]=='i' || str[i]=='t' ||str[i]=='e'){
            mp[str[i]]++;
        }
    }
    int count=0;
    if(mp['n']<3){
        cout<<"0"<<endl;
    }else{

    while(1){
        if(mp['n']<3)
            break;
            else{
                mp['n']-=2;
        }
         if(mp['i']<1)
            break;
            else{
                mp['i']-=1;
        }
        if(mp['e']<3)
            break;
            else{
                mp['e']-=3;
        }
        if(mp['t']<1)
            break;
            else{
                mp['t']-=1;
        }
        count++;
    }

      cout<<count<<endl;
}    }

int main() {
       IO();
       ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
       int T=1;
      // cin>>T;
       while(T--)  {
              decode();
       }

  return 0;
}

#include<bits/stdc++.h>
using namespace std;
string a;
int cnt[5];
int main(void){
	cin>>a;
	int b=a.size();
	for(int i=0;i<b;++i){
		if(a[i]=='n')cnt[1]++;
		if(a[i]=='i')cnt[2]++;
		if(a[i]=='e')cnt[3]++;
		if(a[i]=='t')cnt[4]++;
	}
	int ans=min(min(min(cnt[2],cnt[4]),(cnt[1]-1)/2),cnt[3]/3);
	cout<<ans<<endl;
	return 0;
}

#include<iostream>
#include<string>
using namespace std;
int main() {
	int count[4]{ 0 };
	string stroka;
	getline(cin, stroka);
	for (int i = 0; i < stroka.size(); i++)
	{
		if (stroka[i] == 'n')
			count[0] ++;
		if (stroka[i] == 'i')
			count[1] ++;
		if (stroka[i] == 't')
			count[2] ++;
		if (stroka[i] == 'e')
			count[3] ++;
	}
	if (count[0] > 4)
		count[0] = 1 + ((count[0]-3)/2);
	else
		count[0] = count[0] / 3;
	count[3] = count[3] / 3;
	int max = 100;
	int result;
	for (auto i = 0; i < 4; i++)
	{
		if (count[i] < max)
			max = count[i];
	}
	if (max == 100)
		result = 0;
	else
		result = max;
	cout << result;
}

#include<bits/stdc++.h>
using namespace std;
string a;
int b,c,d,e,sb[4];
int main()
{
	cin>>a;
	for(int i=0;i<a.size();i++)
	{
		if(a[i]=='n')
		b++;
		if(a[i]=='i')
		c++;
		if(a[i]=='e')
		d++;
		if(a[i]=='t')
		e++;
	}
	printf("%d\n",min(min(min(e,c),d/3),(b-1)/2));
	return 0;
}

#include<iostream>
using namespace std;
int main ()
{ ios_base::sync_with_stdio(0);
  string s;  cin>>s;
  int n=0, e=0, i=0, t=0;
  for(int j=0;j<s.size();j++)
  { if(s[j]=='n')n++;  if(s[j]=='i')i++;
    if(s[j]=='e')e++;  if(s[j]=='t')t++;
  }
  if(n>0)n--;
 cout<<min(min((n/2),(i)),min((e/3),(t)));
  return 0;
}

#include<bits/stdc++.h>
using namespace std;
char s[105];
int n,i,e,t;
int main()
{
    scanf("%s",s+1);
    int len=strlen(s+1);
    for(int w=1;w<=len;w++)
    {
        if(s[w]=='n') n++;
        if(s[w]=='i') i++;
        if(s[w]=='e') e++;
        if(s[w]=='t') t++;
    }
    printf("%d\n",min(min(min(t,i),e/3),(n-1)/2));
    return 0;
}

#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <algorithm>
#include <string>
#define MAX 0x7fffffff
#define MIN 0x80000000
#define ll __int64
using namespace std;
char str[101];
int i,len;
int main()
{
	int sum[5]={0};
	scanf("%s",str);
	len=strlen(str);
	for(i=0;i<len;i++)
		if(str[i]=='n')
			sum[1]++;//实际上只用了两个'n'
		else if(str[i]=='i')
			sum[2]++;
		else if(str[i]=='e')
			sum[3]++;
		else if(str[i]=='t')
			sum[4]++;
		printf("%d\n",min(--sum[1]/2,min(sum[2],min(sum[3]/3,sum[4]))));
		return 0;
}

#include<bits/stdc++.h>
using namespace std;int i,a[100000];char s[100000];int main(){for(scanf("%s",s);i<strlen(s);i++)a[s[i]]++;printf("%d",min((a['n']-1)/2,min(a['e']/3,min(a['t'],a['i']))));}

#include<bits/stdc++.h>
using namespace std;

int in(string m,char a){
    for(int i=0;i<m.length();i++)
        if(m[i]==a)
            return 1;
    return 0;
}

int get19count(string m){
    int l=m.length(),n=count(m.begin(),m.end(),'n'),e=count(m.begin(),m.end(),'e');
    if(!in(m,'i') || !in(m,'t') || n<3 || e<3)
        return 0;
    int i=count(m.begin(),m.end(),'i'),t=count(m.begin(),m.end(),'t');
    int c=0,d;
    while(n>1 && e>2 && i>0 && t>0){
        if(c==0)
            n--;
        n-=2;
        e-=3;
        i--;
        t--;
        c++;
    }
    return c;
}

int main(){
    string m;
    cin>>m;
    int c=get19count(m);
    cout<<c;
    return 0;
}

#include <iostream>

using namespace std;

int main() {
    string s;
    int n = 0,  // 3
        i = 0,  // 1
        e = 0,  // 3
        t = 0;  // 1
    cin >> s;

    for (int j = 0; j< s.length(); j++) {
        switch (s[j]) {
            case 'n':
                n++;
                break;
            case 'i':
                i++;
                break;
            case 'e':
                e++;
                break;
            case 't':
                t++;
                break;
        }
    }

    int a = n / 3 + n / 5;
    if (a > 12 || n == 6 || n == 10)
        a--;

    int num [4] = {a, i, e / 3, t};
    int min = num[0];

    for (int j = 1; j < 4; j++)
        if (min > num[j])
            min = num[j];

    cout << min;

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
string s;
int n=0,i=0,t=0,e=0;
int main(){
	cin>>s;
	for(int j=0;j<s.size();j++){
		if(s[j]=='n')n++;
		if(s[j]=='i')i++;
		if(s[j]=='e')e++;
		if(s[j]=='t')t++;
	}
	cout<<min(min(min(t,i),e/3),(n-1)/2)<<endl;
	return 0;
}

#include<iostream>
#include<string>
#include<memory.h>
#include<cmath>
#include<math.h>
#include<algorithm>
using namespace std;
int main()
{
    string st;
    int n=0,I=0,e=0,t=0,count=0;
    cin>>st;
    for(int i=0;i<=st.length()-1;i++)
    {
        if(st[i]=='n')n++;
                if(st[i]=='i')I++;
                        if(st[i]=='t')t++;
                                if(st[i]=='e')e++;
    }
   /* cout<<"n = "<<n<<endl;
    cout<<"i = "<<I<<endl;
    cout<<"t = "<<t<<endl;
    cout<<"e = "<<e<<endl;*/

                                while(n>=3 && e>=3 && I>=1 && t>=1)
                                {
                                count++;
                                n=(n-1)/2;
                                e=e-3;
                                I--;
                                t--;
                                }
                                cout<<count<<endl;
    return 0;
}

#include <iostream>
#include <string>

using namespace std;

int main(){
    string s;
    int n=0,p=0,e=0,t=0,res=0;
    cin >> s;
    for (int i = 0;i<s.length();i++){
        if (s[i] == 'n') n++;
        if (s[i] == 'i') p++;
        if (s[i] == 'e') e++;
        if (s[i] == 't') t++;
    }
    for (;;){
        if (n>=2) n-=2;else break;
        if (p>=1) p-=1;else break;
        if (t>=1) t-=1;else break;
        if (e>=3) e-=3;else break;
        res++;
    }
   cout << res;
}

#include <string>
#include <cstdlib>
#include <iostream>
#include <algorithm>

int cnt[256];

using namespace std;

int main()
{
    string word;

    cin >> word;

    for (int i = 0; i < word.size(); ++i)
        ++cnt[word[i]];

    int ans = cnt['i'];

    ans = min(ans, cnt['t']);
    ans = min(ans, (int)(cnt['n'] / 3));
    ans = min(ans, cnt['e'] / 3);

    cout << ans << endl;

    return EXIT_SUCCESS;
}

#include<iostream>
#include<deque>
#include<stdio.h>
#include<cmath>
#include<string>

using namespace std;

int main(){
    string s;
    cin>>s;
    int m=s.size();
    deque<char> n1,n2,n3,n4;

    for(int j=0;j<m;j++)  {
        if(s[j] =='n')
            n1.push_back(s[j]);
            if(s[j] == 'i')
            n2.push_back(s[j]);
        if(s[j] =='e')
            n3.push_back(s[j]);

        if(s[j]=='t')
            n4.push_back(s[j]); }
    int k1,k2,k3,k4;
    k1=n1.size() ;
    k2=n2.size();
    k3=n3.size();
    k4=n4.size();
    if(k1>2)
        if(k1 % 2 ==0)
            k1=k1/2-1;
            else
                k1=k1/2;
    else
        k1=111111;

    int a,b;
    a=min(min(k2,k3),k4);

    cout<<min(a,k1);
    return 0;
}

#include <stdio.h>
#include <iostream>
#include <string>
#include <map>
#include <math.h>
#include <algorithm>

using namespace std;

int main()
{
	string s;
	cin >> s;
	int m[4];
	for (int i = 0; i < 4; i++)
		m[i] = 0;

	for (int i = 0; i < s.length(); i++)
	{
		if ('n' == s[i])	m[0]++;
		if ('e' == s[i])	m[1]++;
		if ('t' == s[i])	m[2]++;
		if ('i' == s[i])	m[3]++;

	}

	m[0] /= 3;
	m[1] /= 3;

	int mi = m[0];
	if (m[1] < mi) mi = m[1];
	if (m[2] < mi) mi = m[1];
	if (m[3] < mi) mi = m[1];

	cout << mi;

	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main(){
	int tn=0,ti=0,te=0,tt=0,ans=0;
	string s;cin>>s;
	for(int i=0;i<s.size();i++){
		if(s[i]=='n')tn++;
		if(s[i]=='i')ti++;
		if(s[i]=='e')te++;
		if(s[i]=='t')tt++;
	}
	while(tn>=3&&ti>=1&&te>=3&&tt>=1){
		tn-=3;ti--;te-=3;tt--;
		ans++;
	}
	cout<<ans<<endl;
	return 0;
}

#include <iostream>
#include<string>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char** argv) {
	string s;
	cin>>s;
	int n=0,i=0,e=0,t=0;
	for(int j=0;j<s.size();j++){
		if(s[j]=='n'){
			n++;
			if(s[j+1]=='i'){
				if(s[j+1]=='n'){
						n++;
				}

			}
		}
		if(s[j]=='i'){
			i++;

		}
		if(s[j]=='e'){
			e++;
		}
		if(s[j]=='t'){
			t++;
		}
	}

	e=e/3;
   //cout<<n<<" "<<i<<" "<<e<<" "<<t;
	if(n>3&&n%2==1){
		int k=n/3;
		n=n+k;
		n=n/3;
	}
	else {
		int k=n/3;
		n=n+k;
		n=n/3;
	}
	if(n<=i&&n<=e&&n<=t){
		cout<<n;
	}
	else if(i<=n&&i<=e&&i<=t){
		cout<<i;
	}
	else if(e<=n&&e<=i&&e<=t){
		cout<<e;
	}
	else if(t<=n&&t<=i&&t<=e){
		cout<<t;
	}
	return 0;
}

#include<iostream>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{//for(;;){
    string s;
    cin>>s;
    long long a=0,b=0,c=0,d=0,h=0;
    for(int i=0;i<(int)s.length();i++)
    {
        if(s[i]!='n'&&s[i]!='i'&&s[i]!='e'&&s[i]!='t')
            continue;
        else
        {
            if(s[i]=='n')
            {
                a++;
                if(s[i+1]=='i')
                    h++;
            }
            else if(s[i]=='i')
               b++;
            else if(s[i]=='e')
                c++;
            else if(s[i]=='t')
                d++;
        }
    }
    //cout<<a<<"  "<<b<<"  "<<c<<"  "<<d<<endl;
    if(b&&d&&a&&c)
    {
        if(min(a,c)>=3*min(b,d))
            cout<<min(b,d)<<endl;
        else if(a==min(a,c))
        {
                if(a%3!=0)
                {
                    a+=(a/3);
            cout<<min(a,c)/3<<endl;
                }
                else
                {
                    if(!h)
                    a+=b;
                    else
                        a+=h;
                    cout<<min(a,c)/3<<endl;
                }
        }
        else
            cout<<min(a,c)/3<<endl;
    }
    else
        cout<<0<<endl;//}
return 0;
}

#include<conio.h>
#include<locale>
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main()
{
	string s;
	getline(cin, s);
	int arr[4];
	for (int i = 0; i < 4; i++)
	{
		arr[i] = 0;
	}
	for (int i = 0; i < s.size(); i++)
	{
		if (s[i] == 'n')
		{
			arr[0]++;
		}
		else if (s[i] == 'i')
		{
			arr[1]++;
		}
		else if (s[i] == 'e')
		{
			arr[2]++;
		}
		else if (s[i] == 't')
		{
			arr[3]++;
		}
	}
	arr[0] / 3;
	arr[2] / 3;
	int min = 100;
	for (int i = 0; i < 4; i++)
	{
		if (arr[i] < min)
		{
			min = arr[i];
		}
	}
	cout << min;
}

#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main()
{
	int num[4] = { 0,0,0,0 };
	int a, b, c, min;
	std::string s;

	cin >> s;

	a = s.size();

	for (int i = 0; i < a; i++)
	{
		if (s[i] == 'n') num[0]++;
		if (s[i] == 'i') num[1]++;
		if (s[i] == 'e') num[2]++;
		if (s[i] == 't') num[3]++;
	}

	num[0] = num[0] / 3;
	num[2] = num[2] / 3;

	if (num[0] == 1) num[0]++;

	min = num[0];

	for (int i = 0; i < 4; i++)
		if (min > num[i]) min = num[i];

	cout << min;
}

#include<bits/stdc++.h>
using namespace std;

int main ()
{
   string str;
    cin>>str;
    int counts=0, counti=0, counte=0, countn=0, countt=0;

    for(int i=0; i<str.size(); i++)
    {
        if(str[i]=='i') counti++;

        if(str[i]=='e') counte++;
        if(str[i]=='n') countn++;
        if(str[i]=='t') countt++;
    }
   /* cout<<"i="<<counti<<endl;
    cout<<"e="<<counte<<endl;
    cout<<"n="<<countn<<endl;
    cout<<"t="<<countt<<endl;*/

    if(counti == 0 || countt==0 || counte<3 || countn<3) counts=0;
    else{
        /*counts = countn / 3;
        if((counts+1)*3 == )*/

        if(counti>countt) counts = countt;
        else counts = counti;

        //cout<<"1="<<counts<<endl;
        if(counts<=counte/3){
            if(counte/counts < 3 )
            counts--;
        }
        else counts = counte/3;

       // cout<<"2="<<counts<<endl;

        if(counts<=countn/3){
        if(countn/counts < 3)
            counts--;
        }
        else {counts = countn/3;}
        //cout<<"3="<<counts<<endl;
        int p = (countn+(countn%3)) % 3;
        if(countn%3!=0 && countn>=p) counts++;
       // cout<<"4="<<counts<<endl;
    }
    cout<<counts<<endl;
}

#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstdlib>
#include <utility>
#include <cstring>
#include <bitset>
#include <locale>
#include <cctype>
#include <time.h>
#include <vector>
#include <cstdio>
#include <string>
#include <deque>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;

string s,str="",n="nineteen";
map< char , int > mp;
int out,l;

int main()
{
	cin>>str;

	for(int k = 0;k <= str.size(); k++)
	   mp[str[k]]++;

	l = str.size();

	for(;;)
	{
		if(mp['n'] >= 3 && mp['i'] >= 1 && mp['e'] >= 3 && mp['t'] >= 1 )
		{
			s+=n;
			mp['n'] -= 3;
			mp['i'] -= 1;
		    mp['e'] -= 3;
			mp['t'] -= 1;

		}
	    if(mp['n'] >=1 && s[s.size()-1] != 'n' )
		{
			s+='n';
			mp['n']--;
	 	}
	    if(mp['i'] >=1 )
		{
			s+='i';
			mp['i']--;
		}
		if(mp['n'] >=1 )
		{
			s+='n';
			mp['n']--;
		}
		if(mp['e'] >=1 )
		{
			s+='e';
			mp['e']--;
		}
		if(mp['t'] >=1 )
		{
			s+='t';
			mp['t']--;
		}
		if(mp['e'] >=1 )
		{
			s+='e';
			mp['e']--;
		}
		if(mp['e'] >=1 )
		{
			s+='e';
			mp['e']--;
		}
		if(mp['n'] >=1 )
		{
			s+='n';
			mp['n']--;
		}

		if(mp['n'] == 0 && mp['e'] == 0 && mp['t'] == 0 && mp['i'] == 0)
		   break;

	}

	//cout<<s<<endl;

	for(int i = 0; i <= s.size(); i++)
	{
		 if(s[i] == 'n')
		 {
		 	str="";
		    for(int j = i; j <= min(i+7,l); j++)
		        str+=s[j];

           if(str == n)
              out++;
		 }

	}

	cout<<out<<endl;

    return 0;
}

#include <iostream>
#include<string>
#include <algorithm>
#include<cmath>
#include<math.h>
#include<vector>
using namespace std;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	string x = "nineteen";
	string s;
	cin >> s;
	vector <int> y;
	int i, k,j,ct=0;
	while (true)
	{
		for (i = 0; x[i] != '\0'; i++)
		{
			for (k = 0; s[k] != '\0';k++)
			{
				bool f = 0;
				int en = y.size();
				for (j = 0; j < en; j++)
				{
					if (y[j] == k)
					{
						f = 1;
					}
				}
				if (f == 0)
				{
					if (x[i] == s[k])
					{
						y.push_back(k);
						break;
					}

				}
			}
			if (s[k] == '\0')
			{
				cout << ct << endl;
				return 0;
			}
		}
		ct++;
	}

	return 0;
}

#include <iostream>
#include <string.h>

using namespace std;
 int  main()
 {
 	string s;
     cin>>s;
     int l=s.length();
     int n=0,i=0,e=0,t=0;
     for(int j=0;j<l;j++)
     {
     	if(s[j]=='n')
     		n++;

     	if(s[j]=='i')
     		i++;
     		if(s[j]=='e')
     				e++;
     			if(s[j]=='t')
     				t++;
     }
if(n>=3){
int a[4];
//nineteenineteen
a[0]=n/3;
a[1]=i;
a[2]=e/3;
a[3]=t;
int min=a[1];
for (int k = 1; k < 4; k++)
{
	if(a[k]<min)
		min=a[k];
}
if(min<=a[0])
 cout<<min;
 else
 if(min>a[0]&&a[0]%3==2)
 cout<<a[0]+1;
if(min>a[0]&&a[0]%3!=2)
     cout<<a[0];
     }

else cout<<0;

 }

#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <stdio.h>
#include<cmath>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
int main()
{
	string s;
	getline(cin, s);
	map <char, int>Mymap;
	map <char, int>::iterator it;
	vector<int>v(4);
	for (int i = 0; i < s.length(); i++){

		if (s[i] == 'n' || s[i] == 'i' || s[i] == 'e' || s[i] == 't')
		{
			if (Mymap.count(s[i] == 0))Mymap[s[i]] = 1;
			else Mymap[s[i]] += 1;
		}
	}if (Mymap.count('n') == 0)Mymap['n'] = 0;
	if (Mymap.count('e') == 0)Mymap['e'] = 0;
	if (Mymap.count('t') == 0)Mymap['t'] = 0;
	if (Mymap.count('i') == 0)Mymap['i'] = 0;
	string t = "neit"; bool test = true; int ans = 0; int min = 1000000;
	for (int j = 0; j<4; j++){
		if (j == 0 ){
			if (Mymap[t[j]] == 0){ test = false; break;  }
			else {
				if (Mymap[t[j]] % 3 == 2)Mymap[t[j]] += 1;
				ans = Mymap[t[j]] / 3;
				if (min>ans)min = ans;
			}
		}if ( j == 1){
			if (Mymap[t[j]] == 0){ test = false; break; }
			else {

				ans = Mymap[t[j]] / 3;
				if (min>ans)min = ans;
			}
		}
		else {
			if (Mymap[t[j]] == 0){ test = false; break; }
			else {
				ans = Mymap[t[j]] / 1;
				if (min>ans)min = ans;
			}
		}
	}
	if (test != false && min != 1000000)
		cout << min << endl;
	else cout << 0 << endl;

	return 0;
}

#include <iostream>
#include <string>

int min (int n, int i, int e, int t)
{
	int res = n;
	if (i < res)
		res = i;
	if (e < res)
		res = e;
	if (t < res)
		res = t;
	return res;
}

void main ()
{
	std::string word;
	std::cin >> word;

	int n = 0, i = 0, e = 0, t = 0;
	for(int j=0; j<word.size(); j++)
	{
		switch (word[j])
		{
			case 'n': n++;
				break;
			case 'i': i++;
				break;
			case 'e': e++;
				break;
			case 't': t++;
				break;
		}
	}
	n = (n < 5 ? n / 3 : (n < 7 ? (n + 1) / 3 : (n + 2) / 3)); e = e / 3;
	std::cout << min(n, i, e, t);
}

#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <cmath>

using namespace std;
int main()
{
    int n = 0, ic = 0, t = 0, e = 0;
    string str;
    cin >> str;
    for (int i = 0, s = str.size(); i < s; i++)
    {
        if (str[i] == 'n')
            n++;
        else if (str[i] == 'e')
            e++;
        else if (str[i] == 't')
            t++;
        else if (str[i] == 'i')
            ic++;
    }
    int res = 0;
    while ((n >= 3 || n == 2) && ic >= 1 && e >= 3 && t >= 1)
    {
        res++;
        n -= 3;
        e -= 3;
        ic--;
        t--;
    }
    cout << res << endl;

    return 0;
}

/*****Be Name Khoda*****/

#include <bits/stdc++.h>
#define endl '\n'

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	string s;
	cin >> s;
	int n = 0 , i = 0 , t = 0 , e = 0 , ans = 0;
	for(int j = 0; j < s.length(); j++)
	{
		if(s[j] == 'n')
			n++;
		if(s[j] == 'e')
			e++;
		if(s[j] == 'i')
			i++;
		if(s[j] == 't')
			t++;
	}
	while(t-1 >= 0 && n-3 >= 0 && e-3 >= 0 && i-1 >= 0){
		//cout << n << " " << i << " " << t << " " << e << endl;
		ans++ , t-- , n -= 3 , e -= 3 , i--;
	}
	cout << ans << endl;
	return 0;
}

#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main()
{
	string s;

	int nCount = 0;
	int iCount = 0;
	int eCount = 0;
	int tCount = 0;

	int Frq[4] = { 0 ,0 ,0 ,0 };

	getline(cin, s);

	for (int i = 0; i < s.size(); i++)
	{
		if (s[i] == 'n')
			nCount++;
		else if (s[i] == 'i')
			iCount++;
		else if (s[i] == 'e')
			eCount++;
		else if (s[i] == 't')
			tCount++;
	}

	if (nCount > 0 && ((nCount % 3 == 0) || nCount > 3) && iCount > 0 && (iCount % 1 == 0) && eCount > 0 && ((eCount % 3 == 0) || eCount > 3) && tCount > 0 && (tCount % 1 == 0))
	{
		if (nCount > 3)
		{
			if (nCount % 3 == 0 && eCount % 3 ==0)
				Frq[0] += 1;
			nCount = nCount + (nCount / 3);
			Frq[0] += nCount / 3;
			Frq[2] = eCount / 3;
		}
		else
		{
			Frq[0] = nCount / 3;
			Frq[2] = eCount / 3;
		}

		Frq[1] = iCount;
		Frq[3] = tCount;

		sort(begin(Frq), end(Frq));

		cout << Frq[0];
	}
	else
		cout << "0";
}

#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,e,t;
    string s;
    cin>>s;
    for (int j=0; j<s.length(); j++)
    {
        if (s[j]=='n') n++;
        if (s[j]=='i') i++;
        if (s[j]=='e') e++;
        if (s[j]=='t') t++;
    }
    int a[5]={0,n/3,i,e/3,t};
    sort(a+1,a+4+1);
    cout<<a[1];
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int sn=0,si=0,se=0,st=0,n,ans=0;
string s;
int main()
{
	cin>>s;
	n=s.size();
	for(int i=0;i<n;i++)
	{
	  if(s[i]=='n') sn++;
	  else if(s[i]=='i') si++;
	  else if(s[i]=='e') se++;
	  else if(s[i]=='t') st++;
	  if(sn>=3&&si>=1&&se>=3&&st>=1)
	  {
	  	sn-=3;
	  	si-=1;
	  	se-=3;
	  	st-=1;
	  	ans++;
	  }
	}
	cout<<ans;
return 0;
}

#include<iostream>
using namespace std;

int main(){
	string s;
	cin>>s;
	int n=0,i=0,e=0,t=0;
	for(int j=0;j<s.size();j++){
		if(s[j]=='n')
			n++;
		else if(s[j]=='i')
			i++;
		else if(s[j]=='e')
			e++;
		else if(s[j]=='t')
			t++;
	}
	if(e>=3 && n>=3 && t>=1 && i>=1 )
	cout<<min(min(n,i),min(e,t))<<endl;
	else
	cout<<0<<endl;

}

#include<bits/stdc++.h>

#define mem(x,y) memset(x,y,sizeof(x))
#define max(a,b) ((a>b)?a:b)
#define min(a,b) ((a<b)?a:b)
#define diff(a,b) ((a<b)?b-a:a-b)
#define clrstr(a) memset(a,'\0',sizeof(a))
#define CLR(x) memset(x,0,sizeof(x))
#define SET(x) memset(x,-1,sizeof(x))
#define pb(a) push_back(a)
#define pi 2*acos(0)
#define EPS 1e-9
#define inf 10000000
#define MX 100000

using namespace std;

string s;

int main()
{
 ios_base::sync_with_stdio(0);
 int i=0,e=0,n=0,t=0,k,ln,ans,nk=0,ek=0;
 cin>>s;
 ln=s.size();
 for(k=0;k<ln;k++)
    {
     if(s[k]=='n')
        n++;
     else if(s[k]=='i')
        i++;
     else if(s[k]=='t')
        t++;
     else if(s[k]=='e')
        e++;
    }

 //cout<<i<<" "<<t<<" "<<e<<" "<<n<<endl;

 nk=int(n/3);
 e=int(e/3);
 if(n%3 && n>3)
    nk++;
 //cout<<i<<" "<<t<<" "<<e<<" "<<nk<<endl;

 ans=min(t,min(e,min(i,nk)));
 //if(nk>=ans)
    cout<<ans<<endl;
 //else if(n%3==2)
    //cout<<ans<<endl;
 //else cout<<min(ans,nk)<<endl;
}

//Ash145 A. Nineteen
#include<bits/stdc++.h>
#define COMP ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define CLOCK cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
#define rep(i,a,n) for(int i=(a);i<=(n);i++)
#define fori(n) for(int i=0;i<n;++i)
#define forj(n) for (int j=0;j<n;++j)
#define ll long long
#define ull unsigned long long
#define re return
using namespace std;

void solve()
{
	string s;
	cin >> s;
	int n = 0, i =  0, e = 0, t = 0, words;
	string checker = "nineteen";
	forj(s.length())
	{
		if (s[j] == 'n')
			n++;
		else if (s[j] == 'i')
		{
			i++;
		}
		else if (s[j] == 'e')
			e++;
		else if (s[j] == 't')
			t++;
	}
	words = min(min(min(n,i), e), t);
	cout << words;
}

int main()
{
	COMP;
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("error.txt", "w", stderr);
	freopen("output.txt", "w", stdout);
	#endif

	solve();

	CLOCK;
	return 0;
}

#include<bits/stdc++.h>

using namespace std;

int main()
{
    string s;
    cin>>s;
    int ncoun=0,ecoun=0,tcoun=0,icoun=0;
    for(int i=0; i<s.size(); i++)
    {
        if(s[i]=='e')
            ecoun++;
        if(s[i]=='n')
            ncoun++;
        if(s[i]=='t')
            tcoun++;
        if(s[i]=='i')
            icoun++;
    }
    if(ncoun>1)
    cout<<min(min(min(ecoun/3,(ncoun/3)+1),tcoun),icoun);
    else
        cout<<0;
    return 0;
}

#include<bits/stdc++.h>

typedef long long ll;
typedef unsigned long long ull;

#define pi 3.141592653589793238462643383279502884197169399375105820974944592307816406286
#define mod 1000000007

using namespace std;

bool isprime(ull n){if(n<=1)return false;if(n<=3)return true;if(n%2==0||n%3==0)return false;for(ull i=5;i*i<=n;i=i+6)if(n%i==0||n%(i+2)==0)return false;return true;}

long long int gcd(long long int a,long long int b)
{
    if(b==0)
    return a;
    else
    return gcd(b,a%b);
}

long long int exp(long long int value,long long int power)
{
    long long int result=1;
    while(power>0)
    {
        if(power&1LL)
        {
            result*=value;
            result%=mod;
        }
        value*=value;
        value%=mod;
        power/=2LL;
    }
    return result;
}

long long int lcm(ll n1,ll n2)
{
    ll max = (n1 > n2) ? n1 : n2; // maximum value between n1 and n2 is stored in max
    do {
        if (max%n1 == 0 && max%n2 == 0) {
            return max;
        }
        else
            ++max;
    }
    while (true);
}

int isprime(ll n)
{
    if(n==1)
    return 0;
    if(n <= 3)
        return 1;
    if(n%2 == 0 || n%3 == 0)
        return 0;
    for(ll i = 5 ; i*i <= n ; i+=6)
    {
        if(n%i == 0 || n%(i+2) == 0)
            return 0;
    }
    return 1;
}

ll a[1000005];
ll b[1000005];
ll c[1000005];
ll d[1000005];

bool ispalin(ll n)
{
    ll k=0;
    while(n>0)
    {
        a[k]=n%10;
        k+=1;
        n/=10;
    }
    for(ll i=0;i<(k/2);i++)
    {
        if(a[i]!=a[k-i-1])
        return false;
    }
    return true;
}

bool isSorted(ll start,ll end) {
    int flag = 0;
    for(int i=start;i<end;i++) {
        if(a[i]>a[i+1]) {
            flag = 1;
            break;
        }
    }
    if(flag==0) {
        return true;
    }
    return false;
}

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
    //long long int min_,max_,ans,n,sum,f,j,cnt,len,row,col,p,q,r,t,i,k,l,m,x,y,z;

    string s;
    cin>>s;
    int l = s.size();
    int flag = 0;
    int n=0,i=0,e=0,t=0;
    for(int k=0;k<l;k++) {
        if(s[k]=='n') {
            n+=1;
        }
        if(s[k]=='i') {
            i+=1;
        }
        if(s[k]=='e') {
            e+=1;
        }
        if(s[k]=='t') {
            t+=1;
        }
    }
    n/=2;
    e/=3;
    cout<<min(n,min(i,min(e,t)));
}

/*
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
*/

#include<bits/stdc++.h>
using namespace std;

map<char, int> mp;

int main() {
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i++)
        mp[s[i]]++;
    int ans = mp['i'];
    ans = min(ans, mp['t']);
    ans = min(ans, mp['e']/ 3);
    ans = (ans == 1? min(ans, mp['n'] / 3): min(ans, (mp['n'] + 3 - 1) / 3));
    cout << ans << endl;
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

int main()
{    int n,e,i,t,ans=0;
    string s;
    cin>>s;
    map<char,int> m;
    for(int i=0;i<s.size();i++)
    {
        m[s[i]]++;
    }

        if(m['n']%2)
        n=(m['n']/2);//+(m['n']%3);
        else if(m['n']%2==0)
        n=ceil(m['n']/(float)3);
        else
            n=0;
        e=m['e']/3;
        t=m['t']/1;
        i=m['i']/1;
      // cout<<n<<" "<<e<<" "<<i<<" "<<t<<endl;
        ans=min(min(n,e),min(t,i));

    cout<<ans<<endl;
    return 0;
}

#include <iostream>
#include <map>
#include <utility>

using namespace std;

int minimum(map<char, int> mapper) {
    int mini = -1;
    mapper['e'] /= 3;
    if (mapper['n'] > (mapper['i'] * 2)) {
        mapper['n'] = mapper['i'];
    }
    for (map<char, int>::iterator iterator1 = mapper.begin(); iterator1 != mapper.end(); ++iterator1) {
        mini = (mini == -1) ? iterator1->second : (iterator1->second < mini) ? iterator1->second : mini;
    }
    return mini;
}

int main() {
    map<char, int> mapper;

    string ch;
    cin >> ch;
    for (int i = 0; i < ch.length(); i++) {
        if (ch[i] == 'n' || ch[i] == 'i' || ch[i] == 'e' || ch[i] == 't')
            mapper[ch[i]]++;
    }

    cout << minimum(mapper);

    return 0;
}

#include<bits/stdc++.h>
using namespace std;

int main()
{

    string s;
    cin>>s;
    int cntn = 0,cnti = 0,cntt = 0,cnte = 0;
    for(int i=0;i<s.length();i++)
    {
        if(s[i]=='i')
        cnti++;
        if(s[i]=='n')
        cntn++;
        if(s[i]=='t')
        cntt++;
        if(s[i]=='e')
        cnte++;
    }
    if(cnti>0&&cntn>2&&cnte>2&&cntt>0)
    {
        int p=1;
        int ans=0;

        while(p!=0)
        {
          ans++;
          cout<<cntn<<" "<<cnti<<" "<<cntt<<" "<<cnte<<endl;
          cnti--;
          cntn-=2;
          cnte-=3;
          cntt--;
        //   cout<<cntn<<" "<<cnti<<" "<<cntt<<" "<<cnte<<endl;
          if(cnti<=0||cnte<=3||cntt<=0||cntn<=1)
          break;
          //ans++;
        }
        cout<<ans;
    }
    else
    {
        cout<<"0"<<endl;
    }

}

//~In The Name Of Allah~//
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <iomanip>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cmath>
#include <string.h>
#include <sstream>
#include <cstring>
#include <fstream>
#include <functional>
#include <cstdio>
#include <stack>
#include <utility>
#include <set>
#include <list>
#include <queue>
#include <bitset>
using namespace std;

#define all(S) S.begin(), S.end()
#define sortb(S) sort(all(S), greater<ll>())
#define sorta(S) sort(all(S))
#define cinp(N) cin>>N.first>>N.second
#define coutp(N) cout<<N.first<<" "<<N.second<<endl
#define mem(C, V) memset(C, V, sizeof C)
#define clr(S, V) fill(all(S), V)
#define ssum(N) (ll)N*(N+1)/2
#define gt(S) getline(cin, S)
#define sp(N) setprecision(N)<<fixed
#define siz(S) S.size()
#define mk make_pair
#define go continue
#define rep(i, j) for (ll i = 0; i < j; i++)
#define rrep(i, j) for (ll i = j - 1; i > -1; i--)
#define getdis(x1, y1, x2, y2) double(sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2)))
#define Rep(i, j, k) for (ll i = j; i < k; i++)
#define srep(C) for (decltype(C.begin()) it = C.begin(); it != C.end(); it++)
#define pi 3.1415926535897932384626433832795
#define ex 2.7182818284
#define mod 1000000007
#define oo (ll) 2e9

typedef stringstream ss;
typedef string s;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<pii> vpii;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<s> vs;
typedef map<ll, ll> mii;
typedef map<char, ll> mci;
typedef map<s, ll> msi;

int main(){
    //freopen("input.cpp", "r", stdin);
    //freopen("output.cpp", "w", stdout);
    int a, b, c, d, size;
    s str, base = "nineteen";
    cin >> str, a = b = c = d = 0, size = siz(str);
    rep(i, size) if (str[i] == 'n') a++;
    else if (str[i] == 'e') b++;
    else if (str[i] == 'i')c++;
    else if (str[i] == 't') d++;
    //cout << a << " " << b << " " << c << " " << d << endl;
    cout << max(min(min(a / 3 + ((a % 3) + a / 3) / 3, b / 3), min(c, d)), min(min(a / 3 + a / 3 - 1, b / 3), min(c, d))) << endl;
    //cout << min(min(a / 3 + a / 3 - 1, b / 3), min(c, d)) << endl;
    return 0;
}

#include <iostream>
#include <stdio.h>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char** argv) {

	int n, i, e, t, j, min;
	char str[101];

	while(scanf("%s", str) != EOF){
		n = i = e = t = j = 0;
		while(str[j] > 0){
			switch(str[j]){
				case 'n':
					n++;
					break;
				case 'i':
					i++;
					break;
				case 'e':
					e++;
					break;
				case 't':
					t++;
					break;
			}
			j++;
		}
		n = (n / 2 )+1;
		e = e / 3;
		if(n < e)
			min = n;
		else
			min = e;
		if(min > i)
			min = i;
		if(min > t)
			min = t;
		printf("%d\n", min);
	}

	return 0;
}
// 1506949894692

/*
Problem:Nineteen
Author:赵旗
Data:2017-05-01
Description:字符串统计,CF393A
Copyright  2017 赵旗. All rights reserved.
*/
#include<bits/stdc++.h>

typedef long long ll;

using namespace std;

int main( )
{
    ll ans[4]={0,0,0,0};
    char a[120];
    char temp;
    ll length,b;
    gets(a);
    length=strlen(a);
    for(ll i=0;i<length;i++)
    {
        temp=a[i];
        switch(a[i])
        {
            case 'n':ans[0]++;break;
            case 'i':ans[1]++;break;
            case 't':ans[2]++;break;
            case 'e':ans[3]++;break;
        }
    }
    if(ans[1]>1)
        ans[0]/=3;
    else
        ans[0]/=3;
    ans[3]/=3;
    sort(ans,ans+4);
    b=ans[0];
    cout<<b<<endl;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
    int main()
    {
      int i=0,n=0,t=0,e=0;
      string s;
      cin>>s;
      for(auto&a:s)
      {
          switch(a)
          {
          case 'i':
            ++i;
            break;
          case 'n':
            ++n;
            break;
          case 't':
            ++t;
            break;
          case 'e':
            ++e;
            break;
          }
      }
      if(n/2>=min(min(i,t),e/3)-1)
      n+=min(min(i,t),e/3)-1;
      cout<<min(min(i,t),min(e/3,n/3))<<endl;
        return 0;
    }

#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<cctype>
#include<stdio.h>
#include<cstring>
#include<istream>
#include<ostream>
#include<ostream>
#include<sstream>
using namespace std;
typedef long long int lli;

const lli n = 2002;
int prime[n] = {0};
void sieve(){
    prime[1] = prime[0] = 1;
    for (lli i = 2; i < n; i++)     if (!prime[i])          for (lli j = i*i; j < n; j += i)                prime[j] = 1;
    }
int gcd(int a, int b){ if (a%b == 0)return b; else return gcd(b, a%b); }
int g [1000];

int main(){
    //"nineteen";
    string s; cin >> s; int ans = 0;
        for (int i2 = 0; i2 < s.length(); i2++){
            int n1 = s.find("n");
            int i = s.find("i" );
            int n2 = s.find("n");
            int e1 = s.find("e");
            int t = s.find("t");
            int e2 = s.find("e");
            int e3 = s.find("e");
            int n3 = s.find("n");
            if (n1 != -1 && i != -1 && n2 != -1 && e1 != -1 && t != -1 && e2 != -1 && e3 != -1 && n3 != -1){
                ans++;
                s[n1] = ' '; s[i] = ' '; s[n2] = ' '; s[e1] = ' '; s[t] = ' '; s[e2] = ' '; s[e3] = ' '; s[n3] = ' ';
                //cout << s << endl;
            }

        }cout << ans << endl;
        return 0;

}

#include <iostream>
#include <string>
#include <queue>
#include <stdio.h>
#include <string.h>
#include <cstring>
#include <map>
#include <stack>
#include <locale>
#include <set>
#include <functional>
#include <algorithm>
#define pb push_back
#define mp(x,y) make_pair(x,y)
#define SS stringstream
#define ll long long
#define lop(i,v) for (int i = 0; i < v; i++)
#define lop_start(j,v) for (int i = j; i < v; i++)

using namespace std;
int main(){
   // freopen("in.txt","r",stdin);
   // freopen("out.txt","w",stdout);
    ios::sync_with_stdio(false);
    string r;
    while(cin>>r){
        int t=0,i=0,n=0,e=0;
        lop(f,r.length()){
            if(r[f]=='t') t++;
            else if(r[f]=='i') i++;
            else if(r[f]=='n') n++;
            else if(r[f]== 'e') e++;
        }int minmum = min(min(t,i),min(n,e));
        if((minmum==t||minmum==i)){
            if(e>=2*minmum && n>=3*minmum) cout<<minmum<<"\n"; else cout<<"0\n";
        }else cout<<"0\n";
    }
    return 0;
}

//#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <iterator>
#include <set>
#include <algorithm>
#include <cmath>
#include <map>
#include <utility>
#define ll long long
#define s(a) scanf("%lld",&a)
#define p(a) printf("%lld ",a)
#define pp printf("")
#define pn printf("\n")
using namespace std;

int main()
{
    //cout<<"Mike"<<endl;
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    ll n=0,i=0,e=0,t=0;
    cin>>s;
    for(int j=0;j<s.length();j++)
    {
        if(s[j]=='n')
            n++;
        if(s[j]=='t')
            t++;
        if(s[j]=='e')
            e++;
        if(s[j]=='i')
            i++;
    }
    e/=3;
    n=ceil((float)n/3);
    p(min(i,min((n+1)/3,min(e,t))));
    return 0;
}

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define pb push_back
#define ppb pop_back
#define mp make_pair
#define ff first
#define ss second
#define sf scanf
#define pf printf
#define itr iterator
#define SQR(x) ((x) * (x))
#define loop(i, y) for (int i = 0; i < int(y); i++)
#define FOR(i, x, y) for (int i = int(x); i <= int(y); i++)
#define ROF(i, y, x) for (int i = int(y); i >= int(x); i--)
#define ALL(c) c.begin(), c.end()
#define SZ(c) int(c.size())
#define CLR(x, y) memset(x, y, sizeof(x))
#define READ(f) freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)
#define si(x) scanf("%d", &x)
#define sii(x, y) scanf("%d %d", &x, &y)
#define siii(x, y, z) scanf("%d %d %d", &x, &y, &z)
#define sl(x) scanf("%lld", &x)
#define sll(x, y) scanf("%lld %lld", &x, &y)
#define slll(x, y, z) scanf("%lld %lld %lld", &x, &y, &z)
#define sllll(a, b, c, d) scanf("%lld %lld %lld %lld", &a, &b, &c, &d)
#define FileIO                        \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);
#define FastIO                   \
    ios::sync_with_stdio(false); \
    cin.tie(0);
#define FixedPrecision(x)        \
    ios::sync_with_stdio(false); \
    cout.setf(ios::fixed);       \
    cout.precision(x);           \
    cin.tie(0);
#define bitCheck(N, in) ((bool)(N & (1LL << (in))))
#define bitOff(N, in) (N & (~(1LL << (in))))
#define bitOn(N, in) (N | (1LL << (in)))
#define bitFlip(a, k) (a ^ (1LL << (k)))
#define start_time clock_t tStart = clock();
#define execution_time printf("\n>>Time taken: %.10fs\n", (double)(clock() - tStart) / CLOCKS_PER_SEC);
#define popCount(x) __builtin_popcount(x)
#define int2Bin(x, y) \
    bitset<y> z = x;  \
    cout << z.to_string() << endl;
#define tr(it, container) for (auto it = container.begin(); it != container.end(); it++)
#define unq(v) (v).erase(unique(ALL(v)), v.end())
#define common(a, b) sort(ALL(a)), sort(ALL(b)), a.erase(set_intersection(ALL(a), ALL(b), a.begin()), a.end())
#define uncommon(a, b) sort(ALL(a)), sort(ALL(b)), a.erase(set_symmetric_difference(ALL(a), ALL(b), a.begin()), a.end())
#define DB(x) cout << #x << " = " << x << endl
#define DDB(x, y) cout << #x << " = " << x << "   " << #y << " = " << y << endl
#define DDDB(x, y, z) cout << #x << " = " << x << "   " << #y << " = " << y << "   " << #z << " = " << z << endl

template <class T>inline T bigMod(T p, T e, T M){ll ret = 1;for (; e > 0; e >>= 1){if (e & 1)ret = (ret * p) % M;p = (p * p) % M;}return (T)ret;}
template <class T>inline T modInverse(T a, T M) { return bigMod(a, M - 2, M); }
template <class T>inline T gcd(T a, T b){if (b == 0)return a;return gcd(b, a % b);}
template <class T>inline T lcm(T a, T b){a = abs(a);b = abs(b);return (a / gcd(a, b)) * b;}
template <class T>inline T diss(T x1, T x2, T y1, T y2) { return sqrt(((x1 - x2) * (x1 - x2)) + ((y1 - y2) * (y1 - y2))); }
template <class T>inline T disss(T x1, T x2, T z1, T y1, T y2, T z2) { return sqrt(((x1 - x2) * (x1 - x2)) + ((y1 - y2) * (y1 - y2)) + ((z1 - z2) * (z1 - z2))); }
template <class T>inline string int2String(T a){ostringstream str;str << a;return str.str();}
template <class T>inline T string2int(string a){stringstream str(a);T b;str >> b;return b;}
const int dr[] = {0, 1, 0, -1, -1, 1, 1, -1, -2, -2, 2, 2, -1, -1, 1, 1};
const int dc[] = {1, 0, -1, 0, 1, 1, -1, -1, -1, 1, -1, 1, -2, 2, -2, 2};

/// Constants

#define MAXN 1000005
#define MAX 200005
#define MOD 1000000007
#define BASE 1000000009
#define eps 1e-9
#define INF 1llu << 61 // 2,305,843,009,213,693,952
#define inf 1 << 29    // 536,870,912
#define PI acos(-1.0)  // 3.1415926535897932
#define E 2.71828182845904523536

long long fast_power(long long base, long long power) {
    long long result = 1;
    while(power > 0) {

        if(power % 2 == 1) { // Can also use (power & 1) to make code even faster
            result = (result*base) % MOD;
        }
        base = (base * base) % MOD;
        power = power / 2; // Can also use power >>= 1; to make code even faster
    }
    return result;
}

bool is_prime(long long n)
{

    if (n == 1)
        return false;
    for (long long i = 2; (i * i) <= n; i++)
        if (n % i == 0)
            return false;
    return true;
}

bool cmp(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
    return (a.ff > b.ff);
}

int dig_cnt (long long n){return ((int)(log10(n))+1 );}

int main()
{

#ifndef ONLINE_JUDGE
    start_time;
    FileIO;
#else
//FastIO;
#endif

string s; cin >> s;
map < char , int > mpp;
for(auto a : s)mpp[a]++;
if(mpp['n'])mpp['n']+=2;
int ans  = inf;
for(auto a : mpp){
    if(a.ff == 'n' || a.ff == 'i' || a.ff=='t' || a.ff=='e'){
        //cout << a.ff <<" "<< a.ss << endl;
        if(a.ff=='n' || a.ff=='e')a.ss/=3;
        ans = min(ans,a.ss);
    }
}

//if(ans == ((int) (mpp['n']/3)) )ans++;
cout << ans << endl;

#ifndef ONLINE_JUDGE
    execution_time;
#endif

    return 0;
}

#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <map>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define fs(n) for (short i = 0; i < n; ++i)
#define fi(n) for (int i = 0; i < n; ++i)
#define fl(n) for (ll i = 0; i < n; ++i)
#define fc(n) for (auto& it : n)
#define M 1000000007
using namespace std;
typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;

short solve(const string& s, const char& e)
{
	short cnts[4] = { 0 };
	map<char, short> m;
	for (auto c : s)
		++m[c];
	if (m[e] >= 1)
		m[e] += 1;
	cnts[0] = m['n'] / 3;
	cnts[1] = m['e'] / 3;
	cnts[2] = m['t'];
	cnts[3] = m['i'];
	sort(cnts, cnts + 4);
	return cnts[0];
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	string s;
	cin >> s;
	cout <<solve(s, 'n');

	return 0;
}

#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main()
{
	string s;

	int nCount = 0;
	int iCount = 0;
	int eCount = 0;
	int tCount = 0;

	int Frq[4] = { 0 ,0 ,0 ,0 };

	getline(cin, s);

	for (int i = 0; i < s.size(); i++)
	{
		if (s[i] == 'n')
			nCount++;
		else if (s[i] == 'i')
			iCount++;
		else if (s[i] == 'e')
			eCount++;
		else if (s[i] == 't')
			tCount++;
	}

	if (nCount > 0 && ((nCount % 3 == 0) || nCount > 3) && iCount > 0 && (iCount % 1 == 0) && eCount > 0 && ((eCount % 3 == 0) || eCount > 3) && tCount > 0 && (tCount % 1 == 0))
	{
		if (nCount % 3 == 2 || ((nCount / 3 >= 2) && nCount % 3 !=0))
		{
				nCount = (nCount / 3) + 1;
				Frq[0] = nCount;
				Frq[2] = eCount / 3;
		}
		else
		{
			Frq[0] = nCount / 3;
			Frq[2] = eCount / 3;
		}

		Frq[1] = iCount;
		Frq[3] = tCount;

		sort(begin(Frq), end(Frq));

		cout << Frq[0];
	}
	else
		cout << "0";
}

#include<bits/stdc++.h>
#include<string>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int a[4]={};int x;
    for(x=0;x<s.length();x++)

    {
        if(s[x]=='n')
        a[0]++;
        else if(s[x]=='t')
        a[1]++;
        else if(s[x]=='e')
        a[2]++;
        else if(s[x]=='i')
        a[3]++;
        else
        continue;
    }
    a[0]=(a[0]%2!=0)?(a[0]/2):(a[0]/2-1);
    a[2]=a[2]/3;

    sort(a,a+4);
    cout<<a[0];
    return 0;

}

#include<bits/stdc++.h>
using namespace std;
/*-----------------------*/
#define endl        "\n"
#define ff          first
#define ss          second
#define FASTIO     ios_base :: sync_with_stdio(0)
#define C(x)        cout<<#x<<"="<<x<<" "<<endl
#define CC(x,y)     cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl
#define CCC(x,y,z)  cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl
#define LL          long long
#define ULL         unsigned long long
#define PII         pair<int,int>
#define ALL(x)      x.begin(),x.end()
#define P(x)        push(x)
#define PB(x)       push_back(x)
#define PF(x)       push_front(x)
#define PP          pop
#define PPB         pop_back
#define PPF         pop_front
/*------------------------*/
int mini(int a,int b,int c,int d)
{
    return min( a,min( b,min(c ,c)));
}

int main()
{
    string s;
    cin>>s;
    int len=s.length();
    int N=0,I=0,T=0,E=0;
    for(int i=0;i<len;i++)
    {
        if(s[i]=='n') N++;
        else if(s[i]=='i') I++;
        else if(s[i]=='t') T++;
        else if(s[i]=='e') E++;
    }
    int mn;
    if(min(E/3,min(T,E))==1) mn=N/3;
    else mn=N/2+(-1)*(N%2==0)+(N%2!=0)*(N/2>0);
    cout<< mini( mn , E/3 , I , T) <<endl;
}

#include<iostream>
using namespace std;

int main(){

string str;

cin>>str;
int n=0;
int i=0;
int e=0;
int t=0;

for(int k=0; k<str.size();k++){
    if(str[k]=='n') n++;
    if(str[k]=='i') i++;
    if(str[k]=='e') e++;
    if(str[k]=='t') t++;
}

int n_rem = n%3;
n = n/3;

e = e/3;
if(n_rem==2&&n>0)
cout<<min(n,min(i,min(e,t)))+1<<endl;
else cout<<min(n,min(i,min(e,t)))<<endl;
return 0;
}

#include <bits/stdc++.h>
using namespace std;
int arr[26];
int main()
{
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i++) {
        arr[(s[i]-97)]++;
    }
    int min = arr[8];

    min = (arr[19] < min)?arr[19]:min;
    min = ((arr[4]/3) < min)?(arr[4]/3):min;
    if (min > 1) {
            int b =(arr[13]-3)/2 + 1;
            min = (b < min)?b:min;
    }
    min = ((arr[13]/3) < min)?(arr[13]/3):min;

    cout << min << '\n';
}

#include <iostream>
#include <cstring>
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    int c[4] = {0,0,0,0};
    char s[100] = {'\0'};
    std::cin >> s;
    for (int j = 0; j < strlen(s); j++) {
        switch(s[j]){
            case 'n':
                c[0]++;
                break;
            case 'i':
                c[1]++;
                break;
            case 'e':
                c[2]++;
                break;
            case 't':
                c[3]++;
                break;
            default:
                0;
        }
    }
    c[0] = c[0]/3;
    c[2] = c[2]/3;

    int min = c[0];
    for (int i = 1; i < 4; i++) {
        if(c[i]<min)
            min = c[i];
    }

    std::cout << min << std::endl;

	return 0;
}

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stdio.h>
#include <fstream>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#define p(x,y) pair<x,y>
#define SZ(v) (int)v.size()
#define mp(x,y) make_pair(x,y)
#define MOD 1000000007
#define MAXN 200005
#define X first
#define Y second
using namespace std;
typedef long long ll;
string s;
map<char,int> a;
int main(){
	cin>>s;
	for(int i=0;i<SZ(s);i++)
		a[s[i]]++;
	if(a['n'] == 0){cout<<0<<endl;return 0;}
	cout<<min(min(a['n']/2,a['i']),min(a['e']/3,a['t']))<<endl;
}

#include <iostream>

using namespace std;

int main() {
    string s;
    int n = 0,  // 3
        i = 0,  // 1
        e = 0,  // 3
        t = 0;  // 1
    cin >> s;

    for (int j = 0; j< s.length(); j++) {
        switch (s[j]) {
            case 'n':
                n++;
                break;
            case 'i':
                i++;
                break;
            case 'e':
                e++;
                break;
            case 't':
                t++;
                break;
        }
    }

    int a = n / 3;
    if (n == 7)
        a = 3;
    else if (n >= 5)
        a = n / 2;

    int num [4] = {a, i, e / 3, t};
    int min = num[0];

    for (int j = 1; j < 4; j++)
        if (min > num[j])
            min = num[j];

    cout << min;

    return 0;
}

using namespace std;
    /** int t;
    scanf("%d",&t);
	for(int ks=1;ks<=t;ks++)
    {
        printf("Case %d: ",ks);
        scanf("%lld",&n);

    }**/
#include<bits/stdc++.h>
typedef long long  ll;

#define P(a)   cout<<a<<endl
#define PP(a,b) cout<<a<<" "<<b<<endl
#define PPP(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl

#define READ freopen("in.txt","r",stdin)
#define WRITE freopen("ot.txt","w",stdout)

#define rep(x,n) for(__typeof(n) x=0;x<(n);x++)
#define rr(x,n) for(__typeof(n) x=0;x<(n);x++)
#define reps(i,x) for(int  i=0;i<(x.size());i++)
#define rrs(i,x)  for(int i=0;i<x.size();i++)
#define repp(x,n) for(__typeof(n) x=1;x<=(n);x++)
#define FOR(x,m,n) for(__typeof(n) x=(m);x<=(n);x++)
#define foreach(x,n) for(__typeof(n.begin()) x=n.begin();x!=n.end();x++)

#define mp make_pair
#define pb push_back
#define len(s) s.size()
#define sqr(x) ((x)*(x))
#define xx first
#define yy second
#define all(x) x.begin(),x.end()
#define mem(ar,value) memset(ar,value,sizeof(ar))

#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define min4(a,b,c,d) min(min(a,b),min(c,d))
#define max4(a,b,c,d) max(max(a,b),max(c,d))
#define maxall(v) *max_element(all(v))
#define minall(v) *min_element(all(v))

#define n1 cout<<"\n"
#define sf(a) scanf("%lld",&a)
#define pf(a) printf("%lld\n",a)

#define inf (1e15)
#define eps (1e-9)
#define PI acos(-1.0)
#define pi 3.14159265358979323846
#define isEq(a,b) (fabs((a)-(b))<eps)
#define LEADZERO(n) (__builtin_clz(n))
#define TRAILZERO(n) (__builtin_ctz(n))
#define ONBIT(n) (__builtin_popcount(n))
#define Dist(x1,y1,x2,y2) (sqrt(sqr((x1)-(x2))+sqr((y1)-(y2))))
#define spDist(lat1,long1,lat2,long2,r) ((r)*acos(sin(lat1)*sin(lat2)+cos(lat1)*cos(lat2)*cos((long1)-(long2))))

/**Define Bitwise operation**/
#define check(n, pos) (n & (1<<(pos)))
#define biton(n, pos) (n | (1<<(pos)))
#define bitoff(n, pos) (n & ~(1<<(pos)))

///upper bound and lower bound
#define LB(a,value) (lower_bound(all(a),value)-a.begin())
#define UB(a,value) (upper_bound(all(a),value)-a.begin())

///DEBUG
#define dbg(x) cout<<#x<<": "<<x<<endl
#define dbgar(i,a) cout<<#a<<"["<<i<<"] = "<<a[i]<<" "<<endl

const int mod= 1000000007;

template<class T>T gcd(T a,T b){return b == 0 ? a : gcd(b, a % b);}
template<typename T>T lcm(T a, T b) {return a / gcd(a,b) * b;}

template <class T> T extract(string s, T ret) {stringstream ss(s); ss >> ret; return ret;}/// extract words or numbers from a line
template <class T> string tostring(T n) {stringstream ss; ss << n; return ss.str();}/// convert a number to string
template<class T> inline T Mod(T n,T m) {return (n%m+m)%m;} ///For Positive Negative No.

template<class T>T my_pow(T n,T p){if(p==0)return 1;T x=my_pow(n,p/2);x=(x*x);if(p&1)x=(x*n);return x;} ///n to the power p
template<class T>T big_mod(T n,T p,T m){if(p==0)return (T)1;T x=big_mod(n,p/2,m);x=(x*x)%m;if(p&1)x=(x*n)%m;return x;}

template<class T>T multiplication(T n,T p,T m){if(p==0)return (T)0;T x=multiplication(n,p/2,m);x=(x+x)%m;if(p&1)x=(x+n)%m;return x;}
bool isVowel(char ch){ ch=toupper(ch); if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E') return true; return false;}

map<string,ll>MPS;
map<ll,ll>MP;

pair<ll,ll>p[100100];
ll a,b,n,m,res=0,c=0,t=0,ans=0,cc=0,f=0,ff=0,cnt=0;
ll ar[100006]={0};
ll mn=inf,mx=-inf;
ll ar1[1001000]={0};
//ll dp[1005][1005];
ll dp[555555];
//vector<ll>vv;
//vector<ll>v;
ll vis[200100];
string s,ss;//,ch[100010];

int main()
{
    ios_base::sync_with_stdio(false);
    s="nineteen";
    cin>>ss;
    ll c=0;
    rrs(i,ss)
    {
        MP[ss[i]]++;
    }
    ll n=MP['n'];

    n=(n%3!=0)+(n/3);
    ll i=MP['i'];
    ll e=MP['e'];
    e=(e%3!=0)+(e/3);
    t=MP['t'];
   // cout<<n<<" "<<i<<" "<<e<<" "<<t<<endl;
    //cout<<c;
    ll res;
    res=min4(n,i,e,t);
   // cout<<res<<endl;
    for( i=0;i<len(ss)-7;i++)
    {
        if(ss.substr(i,8)==s)c++;
    }
    ll cc=0;

    cout<<max3(cc,c,res);

    return 0;
}

#include <iostream>
#include <string>
using namespace std;
int main(){
    string X;
    cin>>X;
    char y[4]={'n','i','t','e'};
    int c,arr[4],f=0;
    for(int I=0;I<4;I++){
            c=0;
        for(int i=0;i<X.size();i++){
            if(y[I]==X[i]){
                c++;
            }
    }
    arr[f]=c;
    f++;
    }
    cout<<min(((arr[0]-1)/2,arr[1]),((arr[2]),arr[3]/3))<<endl;
    return 0;
}

#include<iostream>
#include<string>
using namespace std;
int main() { string s; int n=0,e=0,i=0,t=0,min,check=0;
cin>>s;
for(int j=0;j<s.size();j++)
{   if(s[j]=='n')
        n++;
    else if(s[j]=='e')
        e++;
    else if(s[j]=='i')
        i++;
    else if(s[j]=='t')
        t++; }
if((n==3)||(n%3==0))
    n/=3;
else if(n>3)
    n=((n/3)+1);
else n=0;
if(e%3)
    while(e%3)
        e--;
e/=3;
    min=e;
if(n<min)
    min=n;
if(i<min)
    min=i;
if(t<min)
    min=t;
cout<<min<<endl;
return 0; }

#include<bits/stdc++.h>
using namespace std;
int n,i,e,t,m=101;
int main()
{
	char a[101];
	gets(a);
	for(int ii=0;ii<=strlen(a)-1;ii++)
	{
		if(a[ii]=='n')
		{
			n++;
		}
		if(a[ii]=='i')
		{
			i++;
		}
		if(a[ii]=='e')
		{
			e++;
		}
		if(a[ii]=='t')
		{
			t++;
		}
	}
	n=n/3;
	e=e/3;
	m=min(m,n);
	m=min(m,e);
	m=min(m,i);
	m=min(m,t);
	cout<<m;
}

#include <iostream>
#include<string>
#include <iomanip>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <algorithm>
#include <sstream>
#include <iterator>

using namespace std;

int main() {
	string s;
	cin >> s;
	vector<int> res(4);

	for (size_t i = 0; i < res.size(); i++)
	{
		res[i] = 0;
	}
	for (size_t i = 0; i < s.size(); i++)
	{
		if (s[i] == 'n') res[0] += 1;
		if (s[i] == 'e') res[1] += 1;
		if (s[i] == 'i') res[2] += 1;
		if (s[i] == 't') res[3] += 1;
	}
	//cout << res[0] << res[1] << res[2] << res[3] << endl;
	int left = res[0] % 3;
	if(res[0]%3==2)res[0] = res[0] / 3 +1;
	else res[0] = res[0] / 3;
	if ((res[0]+1)%3==0) res[0]++;

	res[1] = res[1] / 3;
	//cout << res[0] << res[1] << res[2] << res[3] << endl;
	int x = min(res[0],res[1]);
	x = min(x, res[2]);
	x = min(x, res[3]);
	cout << x;
	//system("pause");
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
   int ee,nn,ii,tt;
    map<char,int>m;
    map<char,int>::iterator it;
    int su=0;
    char c[1000];
    cin>>c;
    if(c=="nineteenineteen")cout<<2;
    else
    for(int i=0;i<strlen(c);i++){
            if(c[i]=='e'||c[i]=='i'||c[i]=='n'||c[i]=='t')
        m[c[i]]++;
    }
    for(it=m.begin();it!=m.end();it++){
      if(it->first=='e')ee=it->second;
      if(it->first=='i')ii=it->second;
      if(it->first=='n')nn=it->second;
      if(it->first=='t')tt=it->second;
    }
    int sum=0;
    while(ee>=3&&nn>=3&&ii>=1&&tt>=1){
        sum++;
        ee=ee-3;
        nn=nn-3;
        ii=ii-1;
        tt=tt-1;
    }
    cout<<sum;
}

#include<iostream>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int a=0,b=0,c=0,d=0;
    for(int i=0;s[i]!='\0';i++)
    {
        if(s[i]=='e')
        {
            a++;
        }
        if(s[i]=='n')
        {
            b++;
        }
        if(s[i]=='i')
        {
            c++;
        }
        if(s[i]=='t')
        {
            d++;
        }
    }
    int ans=(a+b+c+d);
    cout<<ans/8;
    return 0;
}

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int cnt1=0,cnt2=0,cnt3=0,cnt4=0;
	int i;
	for(i=0;i<s.size();i++)
	{
		if(s[i]=='n')
			cnt1++;
		else if(s[i]=='i')
			cnt2++;
		else if(s[i]=='t')
			cnt3++;
		else if(s[i]=='e')
			cnt4++;
	}
	vector<int> v;
	v.push_back(cnt1/3);
	v.push_back(cnt2);
	v.push_back(cnt3);
	v.push_back(cnt4/3);
	sort(v.begin(),v.end());
	cout<<v.front();
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define For(i , x) for (size_t  i = 1 ; i <= x ;++i)
#define rep(k ,h) for ( size_t  k = 0 ; k < h ;k++)
#define scan(k) scanf("%d" , &k)

////// --------------------------  /////////

using namespace std;
int main() {
    string line;
    int c[4] = { 0 };
    cin >> line;
    for (size_t i = 0; i < line.size(); i++) {
        if (line[i] == 'n')
            c[0]++;
        if (line[i] == 'i')
            c[1]++;
        if (line[i] == 't')
            c[2]++;
        if (line[i] == 'e')
            c[3]++;
    }

    c[0]--;
    c[0] = c[2] / 2;
    c[3] = c[3] / 3;
    int min = c[0];
    if (c[2] < min)
        min = c[3];
    if (c[1] < min)
        min = c[1];
    if (c[3] < min)
        min = c[3];
    cout << min << endl;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
int main () {
	string s;
	int ans=0,b=0,c=0,d=0,f=0;
	cin>>s;
	for (int i=0; i<s.size();i++){
		if (s[i]=='n')
		ans++;
		else if (s[i]=='e')
		b++;
		else if (s[i]=='t')
		c++;
		else if (s[i]=='i')
		d++;
	}
			if (ans>4) while (ans>=2 && d>=1 && b>=3 && c>=1) {
			f++;
			ans-=2;
			d-=1;
			b-=3;
			c-=1;}
			else if (ans<=4) cout<<"1";                                                                                cout<<"1";
	cout<<f;
	return 0;
}

#include <iostream>
#include <string>

    using namespace std;

    int main()
    {
    	string p;
    	int cont = 1000,contString[] = {0,0,0,0}, num;
    	cin >> p;

    	for (char x:p)
    	{
    		if (x =='n')
    			contString[0] +=1;
    		else if(x == 'e')
    			contString[1] +=1;
    		else if(x == 't')
    			contString[2] +=1;
    		else if(x == 'i')
    			contString[3] +=1;
    	}

    		num = (contString[0]- contString[0]%3)/3;
    		if ( num < cont)
    			cont = num;
    	  num = (contString[1]- contString[1]%3)/3;
    		if ( num < cont)
    			cont = num;
        num = (contString[2]- contString[2]%1);
    		if ( num < cont)
    			cont = num;
        num = (contString[3]- contString[3]%1);
    		if ( num < cont)
    			cont = num;
    	cout << cont<<endl;
    	return 0;
    }

#include <iostream>

using namespace std;

int main()
{
    string nien;
    int n=0,i=0,e=0,sum=0,t=0;
    cin>>nien;
    for(int p=0; p<nien.size(); p++)
    {
        if(nien[p]=='n')
            n++;
        else if(nien[p]=='i')
            i++;
        else if(nien[p]=='e')
            e++;
        else if(nien[p]=='t')
            t++;

    }
   // cout<<t<<n<<e<<i;

while ((t !=0 and n !=0 and i !=0 and e !=0)and(t>=1 and i>=1 and e>=3 and n>=3)){
    sum++;
    n-=3;
    t--;
    i--;
    e-=3;
}
cout<<sum;

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
//#define debug
#ifdef debug
#define c(a) cout<<#a<<" "<<a<<endl;
#else
#define c(a)
#endif
#define PB push_back
#define MP make_pair
#define f(i,a,b) for(int i=(a);i<(b);++i)
#define fe(i,a,b) for(int i=(a);i<=(b);++i)
int n_n=0;
int n_i=0;
int n_e=0;
int n_t=0;
string s;
int i=0;
//ihimeitimrmhriemsjhrtjtijtesmhemnmmrsetmjttthtjhnnmirtimne
//nmehhjrhirniitshjtrrtitsjsntjhrstjehhhrrerhemehjeermhmhjejjesnhsiirheijjrnrjmminneeehtm
int solve() {
	int  n=s.length() ;
	f(i,0,n){
		if(s[i]=='n')
		n_n++;
		if(s[i]=='i')
		n_i++;
		if(s[i]=='e')
		n_e++;
		if(s[i]=='t')
		n_t++;
	}
	c(n_n);
	c(n_i);
	c(n_e);
	c(n_t);
	return min(min(n_i,n_t),min((n_n/3+n_n)/3,n_e/3));
}
void run() {
	cin>>s;
	cout<<solve()<<endl;
}
int main() {
//	while(1)
	run();
}

#include<iostream>
using namespace std;
int main(void){
    string l;
    cin >> l;
    string nineteen = "niet";
    int nineteenLength = nineteen.length();
    int lLength = l.length();
    int arr[4]={0};
    int i,j;//counter
    for(i = 0; i < lLength; i++){
        for(j = 0; j < nineteenLength; j++){
            if(l[i] == nineteen[j]){
                arr[j]++;
                break;
            }
        }
    }
    int min = lLength;
    {
        arr[2] = arr[2]/3;
    }
    for(i = 1; i < nineteenLength; i++){
        if(min > arr[i]){
            min = arr[i];
        }
        if(min*3-arr[0] > min-1){
            min = arr[0]/3;
        }
    }
    cout << min<< endl;
}

#include <iostream>
#include<string>
#include<algorithm>
using namespace std;
long long tolong(string x)
{
    return (long long)atoi(x.c_str());
}
int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    int arr[1454];
    for(int t=0; t<300; t++)arr[t]=0;
    string x;
    cin>>x;
    for(int v=0; v<x.length(); v++)arr[(int)x[v]]++;
    int arr2[4554]; arr2[0]=arr[(int)'n']/2,arr2[1]=arr[(int)'i'],arr2[2]=arr[(int)'e']/3,arr2[3]=arr[(int)'t'];
     sort(arr2,arr2+4);
    cout<<arr2[0]<<endl;
}

#include<iostream>
using namespace std;
int main ()
{ ios_base::sync_with_stdio(0);
  string s;  cin>>s;
  int n=0, e=0, i=0, t=0;
  for(int j=0;j<s.size();j++)
  { if(s[j]=='n')n++;  if(s[j]=='i')i++;
    if(s[j]=='e')e++;  if(s[j]=='t')t++;
  }
 cout<<min(min((n/3),(i)),min((e/3),(t)));
  return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int n,t,i,e;
    n=count(s.begin(),s.end(),'n')/3;
    e=count(s.begin(),s.end(),'e')/3;
    t=count(s.begin(),s.end(),'t');
    i=count(s.begin(),s.end(),'i');
    int min=n<e?n:e;
    int min1=t<i?t:i;
    cout<<(min<min1?min:min1);
}

#include<bits/stdc++.h>
using namespace std;
string n="nineteen";
int x[4];
int main()
{
	string s;
	cin>>s;
	int n=0;
	for(int i=0;i<s.size();i++)
	{
	  if(s[i]=='i')x[0]++;
	  else if(s[i]=='e')x[1]++;
	  else if(s[i]=='t')x[2]++;
	  else if(s[i]=='n')x[3]++;
	}
	x[1]/=3;
	x[3]/=3;

	int m=*min_element(x,x+4);
	int res=0;
	(x[3]-(m-1))<=m?res=m:res=x[3];

	cout<<min(m,res);

    return 0;
}

#include<iostream>
#include<string>
#include<cmath>
using namespace std;
int main()
{
    int n = 0, i = 0, t = 0, e = 0;
    string s;
    cin >> s;
    for (int f = 0; f<s.size(); f++)
    {
        if (s[f] == 'n')
        {
            n++;
        }
        else if (s[f] == 'i')
        {
            i++;
        }
        else if (s[f] == 'e')
        {
            e++;
        }
        else if (s[f] == 't')
        {
            t++;
        }
    }

    float x = (float)n / 3;
    n=(int)floor(x + 0.5);
    e = e / 3;

    if (i == n&&i == e&&i == t)
    {
        cout << i << endl;
    }
    else if (i == t)
    {
        if (n >= e&&e >= i)
            cout << i << endl;
        else if (e >= n&&n >= i)
            cout << i << endl;
        else
            goto end;
    }
    else if (i < t)
    {
        if (n >= e&&e >= i)
            cout << i << endl;
        else if (e >= n&&n >= i)
            cout << i << endl;
        else
            goto end;
    }
    else if (t < i)
    {
        if (n >= e&&e >= t)
            cout << t << endl;
        else if (e >= n&&n >= t)
            cout << t << endl;
        else
            goto end;
    }

    else
    {
    end:
        cout << "0" << endl;
    }

    return 0;
}

#include<bits/stdc++.h>

using namespace std;

int a[100];string str;
void nineteen()
{
    cout<<min(a['n']/3,min(a['e']/3,min(a['t'],a['i'])));
}

int main()
{
	for(int i=0;i<str.size();i++)
        a[str[i]]++;
	nineteen();
	return 0;
}

#include<bits/stdc++.h>
#include <string.h>
using namespace std ;
int main()
{
 int n=0,t=0,d=0,e=0,r=0,c=0;
 string s; getline(cin,s);
 c=s.size();
for (int i = 0; i < c; ++i)
{

      switch ( s[i] )
      {
         case 'n':
            n++;
            break;
         case 'i':
            d++;
            break;
          case 't':
            t++;
            break;
         case 'e':
            e++;}
}
   while(n>=3 and d!=0 and t!=0 and e>=3){
   r++;
   n=n-3;
   e=e-3;
   d--;
   t--;
   }
if (t==0 or d==0)
   cout<<r;
else if(t>=d)
    cout<<r+d;
else if(t<=d)
    cout<<r+t;

}

#include <iostream>

using namespace std;

int arr[100+10];

int main()
{
    int counter[4]={0,0,0,0};
    string str,help="nite";
    cin>>str;
    for (int i=0;i<str.size();i++)
    {
        for (int j=0;j<4;j++)
        {
            if (str[i]==help[j])
            {
                counter[j]++;
            }
        }
    }
    if (counter[0]%3==2)
    {
        counter[0]++;
    }
    cout<<min(counter[0]/3,min(counter[1],min(counter[2],counter[3]/3)));
    return 0;
}

#include<bits/stdc++.h>
#include<map>
using namespace std;
int main()
{
    int min=1<<31;
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    map<char,int>m;
    cin>>s;
    for(int i=0;i<s.length();i++)
        if(s[i]=='n'||s[i]=='i'||s[i]=='t'||s[i]=='e')
            m[s[i]]++;
    for(auto it=m.begin();it!=m.end();it++)
    {
        if(it->second<min)
            min=it->second;
    }
    cout<<min<<endl;
    return 0;
}

#include <iostream>
#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main(void)
{
    string str; cin >> str;
    int mi = 999;
    mi = min((count(str.begin(), str.end(), 'n')/3), (count(str.begin(), str.end(), 'e')/3));
    int ma = min((count(str.begin(), str.end(), 'i')), (count(str.begin(), str.end(), 't')));
    mi = min(ma,mi);

    if((count(str.begin(), str.end(), 'n')/3) <= (count(str.begin(), str.end(), 'e')/3) && (count(str.begin(), str.end(), 'n')/3) > 1 && (count(str.begin(), str.end(), 'n')/3) & 1)
    {
        if(mi < ma)
        {
            cout << mi + 1;
            return 0;
        }

    }

    cout << mi;
    return 0;
}

#include<bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;

int main()
{
    string s;
    cin>>s;
    int n=0,e=0,i=0,t=0,l,j,c,m;
    l=s.size();
    for(j=0;j<l;j++)
    {
        if(s[j]=='n')
            n++;

        if(s[j]=='e')
            e++;

        if(s[j]=='i')
            i++;

        if(s[j]=='t')
            t++;
    }
    m=min(i,t);
    for(j=1;j<=m;j++)
    {
        if(j<=t && j<=i && (3*j)<=n && (3*j)<=e)
            c=j;
    }
    cout<<j-1;
}

//IN THE NAME OF MY CREATOR//
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    int l;
    cin>>s;
    int a=0,b=0,c=0,d=0;
    for(int i=0;i<=s.size();i++)
    {
        if(s[i]=='i')
            a++;
            else if(s[i]=='n')
                b++;
            else if(s[i]=='e')
                c++;
            else if(s[i]=='t')
                d++;
    }

 l=min(min(b/2,a),min(c/3,d));

        cout<<l<<endl;
    return 0;
}

#include<iostream>
#include<string>
using namespace std;

int main() {
	string str;
	cin >> str;
	int n = 0;
	int i = 0;
	int e = 0;
	int t = 0;
	for (int k = 0;k < str.size();k++) {
		switch (str[k])
		{
		case'n':
			n++;
			break;
		case'i':
			i++;
			break;
		case'e':
			e++;
			break;
		case't':
			t++;
			break;
		default:
			break;
		}
	}
	if (n >= 3) n = n / 2 + n%2; else n = 0;
	e /= 3;
	int min = n;
	if (min > i) min = i;
	if (min > e) min = e;
	if (min > t) min = t;
	cout << min;
	return 0;
}

#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
using namespace std;
int n, i, e, t;
int a, b, c, d;
int main() {
	string s;
	cin >> s;
	for (int a = 0;a < s.size();a++) {
		if (s[a] == 'n') {
			n++;
		}
		else if (s[a] == 'i') {
			i++;
		}
		else if (s[a] == 'e') {
			e++;
		}
		else if (s[a] == 't') {
			t++;
		}
	}
	while (n != 0 && n >= 3) {
		n = n - 3;
			a++;
	}
	while (i != 0 && i >= 1) {
		i = i - 1;
			b++;
	}
	while (e != 0 && e >= 3) {
		e = e - 3;
			c++;
	}
	while (t != 0 && t >= 1) {
		t = t - 1;
			d++;
	}
	/*cout << n << e << i << t << endl;
	a = a + (n / 3);
	b = i;
	c = c + (e / 3);
	d = t;*/
	cout << (min(min(min(a, b), c), d)) << endl;
	return 0;
}

#include <iostream>

using namespace std;

int main() {
    string w ;
    cin >> w;
    int i=0, n=0, e=0, t=0;

    for (int j=0; (int) j< w.size() ;j++){

        if (w[j] == 'i')
            i++;
        else if (w[j] == 'n')
            n++;
        else if (w[j] == 'e')
            e++;
        else if (w[j] == 't')
            t++;

    }

    int count = n < 5 ? min(n/3, min(e/3, min(t,i))):min(n/2, min(e/3, min(t,i)));
    cout<<count<<endl;
    return 0;
}

#include<iostream>
#include<string>
using namespace std;

int check(int&N, int&I, int&E, int&T)
{
	int count = 0;
	while (N > 2 && I > 0 && E > 2 && T > 1)
	{
		N -= 3; I -= 1; E -= 3; T -= 1;
		count++;
	}
	return count;
}

int main()
{
    int n = 0, i = 0, e = 0, t = 0;
	string s;
	cin >> s;
	for (register int j = 0; j < s.length(); j++)
	{
		switch (s[j])
		{
		case 'n':
			n++;
			break;
		case 'i':
			i++;
			break;
		case 'e':
			e++;
			break;
		case 't':
			t++;
			break;
		}
	}
	cout << check(n, i, e, t);
	return 0;
}

#include <iostream>
#include <string>
using namespace std;
int main () {
	string s;
	cin>>s;
	int z=s.size();
	int n=0;
	int i=0;
	int e=0;
	int t=0;
	int n1=0;
	int e1=0;
	for (int k=0; k<z; k++){
		if (s[k]=='n')
		n++;
		if (s[k]=='i')
		i++;
		if (s[k]=='e')
		e++;
		if (s[k]=='t')
		t++;
}
if (n>=3){
	while (n>=3)
	n=n-3;
	n1++;
}
if (e>=3){
	while (e>=3)
	e=e-3;
	e1++;
}
int d[4];
d[0]=n1;
d[1]=i;
d[2]=e1;
d[3]=t;
int ans=d[0];
for (int k=1; k<4; k++)
if (ans>d[k])
ans=d[k];
cout<<ans;
	return 0;
}

//~In The Name Of Allah~//
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <iomanip>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cmath>
#include <string.h>
#include <sstream>
#include <cstring>
#include <fstream>
#include <functional>
#include <cstdio>
#include <stack>
#include <utility>
#include <set>
#include <list>
#include <queue>
#include <bitset>
using namespace std;

#define all(S) S.begin(), S.end()
#define sortb(S) sort(all(S), greater<ll>())
#define sorta(S) sort(all(S))
#define cinp(N) cin>>N.first>>N.second
#define coutp(N) cout<<N.first<<" "<<N.second<<endl
#define mem(C, V) memset(C, V, sizeof C)
#define clr(S, V) fill(all(S), V)
#define ssum(N) (ll)N*(N+1)/2
#define gt(S) getline(cin, S)
#define sp(N) setprecision(N)<<fixed
#define siz(S) S.size()
#define mk make_pair
#define go continue
#define rep(i, j) for (ll i = 0; i < j; i++)
#define rrep(i, j) for (ll i = j - 1; i > -1; i--)
#define getdis(x1, y1, x2, y2) double(sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2)))
#define Rep(i, j, k) for (ll i = j; i < k; i++)
#define srep(C) for (decltype(C.begin()) it = C.begin(); it != C.end(); it++)
#define pi 3.1415926535897932384626433832795
#define ex 2.7182818284
#define mod 1000000007
#define oo (ll) 2e9

typedef stringstream ss;
typedef string s;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<pii> vpii;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<s> vs;
typedef map<ll, ll> mii;
typedef map<char, ll> mci;
typedef map<s, ll> msi;

int main(){
    //freopen("input.cpp", "r", stdin);
    //freopen("output.cpp", "w", stdout);
    int a, b, c, d, size, tmp = 0;
    s str, base = "nineteen";
    cin >> str, a = b = c = d = 0, size = siz(str);
    rep(i, size) if (str[i] == 'n') a++;
    else if (str[i] == 'e') b++;
    else if (str[i] == 'i')c++;
    else if (str[i] == 't') d++;
    rep(i, size){
        int idx1 = i, idx2 = 0;
        while (str[idx1] == base[idx2] && idx1 < size && idx2 < 8) idx1++, idx2++;
        tmp += (idx2 == 8);
    }
    cout << max(min(min(a / 3 + (a % 3), b / 3), min(c, d)), tmp) << endl;
    return 0;
}

#include <iostream>
#include<string>
#include <iomanip>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <algorithm>
#include <sstream>
#include <iterator>

using namespace std;

int main() {
	string s;
	cin >> s;
	vector<int> res(4);

	for (size_t i = 0; i < res.size(); i++)
	{
		res[i] = 0;
	}
	for (size_t i = 0; i < s.size(); i++)
	{
		if (s[i] == 'n') res[0] += 1;
		if (s[i] == 'e') res[1] += 1;
		if (s[i] == 'i') res[2] += 1;
		if (s[i] == 't') res[3] += 1;
	}
	res[0] = res[0] / 3;
	res[1] = res[1] / 3;
	int x = min(res[0],res[1]);
	x = min(x, res[2]);
	x = min(x, res[3]);
	cout << x;
	//system("pause");
	return 0;
}

#include <iostream>
#include <string>
using namespace std;
int main()
{
	string s;
	cin >> s;
	int x = 0;
	for (int i = 0; i < s.size(); i++)
	{
		string s2=s;
		for (int z = 0; z < s.size(); z++)
		{
			s2[z] = ' ';
		}
		if (s[i] == 'n')
		{
			swap(s2[i], s[i]);
			for (int j = 0; j < s.size(); j++)
			{
				if (s[j] == 'i')
				{
					swap(s2[j], s[j]);
					for (int k = 0; k < s.size(); k++)
					{
						if (s[k] == 'n')
						{
							swap(s2[k], s[k]);
							for (int l = 0; l < s.size(); l++)
							{
								if (s[l] == 'e')
								{
									swap(s2[l], s[l]);
									for (int m = 0; m < s.size(); m++)
									{
										if (s[m] == 't')
										{
											swap(s2[m], s[m]);
											for (int n = 0; n < s.size(); n++)
											{
												if (s[n] == 'e')
												{
													swap(s2[n], s[n]);
													for (int b =0; b < s.size(); b++)
													{
														if (s2[b] == 'e')
														{
															swap(s2[b], s[b]);
															for (int v = 0; v < s.size(); v++)
															{
																if (s2[v] == 'n')
																{
																	swap(s2[v], s[v]);
																	x++;
																}
															}
														}
													}
												}
											}
										}
									}
								}
							}
						}
					}

				}
			}

		}
	}
	cout << x << endl;

}

#include<bits/stdc++.h>
using namespace std;

int main(){
/*
letras[0] = n
letras[1] = i
letras[2] = t
letras[3] = e
*/
	char s[101];
	int letras[4] = { 0 };
	cin>>s;
	int n = strlen( s );
	for( int i=0 ; i<n ; i++ ){
		if( s[i] == 'n' ){
			letras[0]++;
		}else if( s[i] == 'i' ){
			letras[1]++;
		}else if( s[i] == 't' ){
			letras[2]++;
		}else if( s[i] == 'e' ){
			letras[3]++;
		}
	}
	letras[0] = letras[0]/3;
	letras[3] = letras[3]/3;
	if( letras[1] == letras[2] == letras[3] == letras[0]+1  ){
		letras[0]++;
	}
	int Min = 102;
	for( int i=0 ; i<4 ; i++ ){
		Min = min( letras[i] , Min );
	}
	cout<<Min;
	return 0;
}

#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif
#include <iostream>
#include <cmath>
#include <iomanip>
#include <string>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <stdio.h>
#include <climits>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <sstream>
#include <map>
#include <ctime>
#include <cstdlib>
#include <list>
#include <bitset>
#include <functional>
#include <numeric>
#include <utility>
#include <array>

using namespace std ;

void Hima(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}

int main ()
{
    Hima();
    string s;
    cin>>s;
    int n=0,i=0,t=0,e=0,c=0;
    int sz=s.size();
    for(int j=0;j<sz;j++)
    {

        if(s[j]=='n')
            { n++;
        if(j>2&&s[j-1]=='e'&&s[j+1]=='i') n++;
        }
        else if(s[j]=='i') i++;
        else if(s[j]=='t') t++;
        else if(s[j]=='e') e++;
    }
    cout<<n<<" "<<e<<" "<<i<<" "<<t<<endl;
    //--------------------------------

    if(n>3&&n%2==1)
    {
        int y=n/2;
        n=y*3;
    }

    while(i>=1&&t>=1&&n>=3&&e>=3)
    {
        n-=3;
        e-=3;
        i--;
        t--;
        c++;
    }

    cout<<c<<endl;
    return 0;
}

/*
if(n>=5&&n%3!=0)
     {n++;
         while(n%3!=0&&n>=5) n++;
    }
    cout<<n<<" "<<e<<" "<<i<<" "<<t<<endl;
    while(i>=1&&t>=1&&n>=3&&e>=3)
    {
        n-=3;
        e-=3;
        i--;
        t--;
        c++;
    }

    cout<<c<<endl;
*/

#include<bits/stdc++.h>
using namespace std;

int in(string m,char a){
    for(int i=0;i<m.length();i++)
        if(m[i]==a)
            return 1;
    return 0;
}

int get19count(string m){
    int l=m.length(),n=count(m.begin(),m.end(),'n'),e=count(m.begin(),m.end(),'e');
    if(!in(m,'i') || !in(m,'t') || n<3 || e<3)
        return 0;
    int i=count(m.begin(),m.end(),'i'),t=count(m.begin(),m.end(),'t');
    int c=0;
    while(n>2 && e>2 && i>0 && t>0){
        n-=3;
        e-=3;
        i--;
        t--;
        c++;
    }
    return c;
}

int main(){
    string m;
    cin>>m;
    int c=get19count(m);
    cout<<c;
    return 0;
}

#include <map>
#include <cstdio>
#include <iostream>
using namespace std;

int main() {
	string Or = "nineteen";
	map<char, int> OrC;
	for(int i = 0; i < Or.size(); i++) {
		OrC[Or[i]]++;
	}

	string s;
	map<char, int> sC;
	cin >> s;
	for(int i = 0; i < s.size(); i++) {
		sC[s[i]]++;
	}

	int per = 888;
	int pernN = 888;
	bool f = true;
	bool allP = true;
	for(map<char, int>::iterator it = OrC.begin(); it != OrC.end(); it++) {
		int orCC = it->second;
		int sCC = sC[it->first];

		if(!f && it->first != 'n') {
			if(sCC/orCC != pernN) {
				allP = false;
			}
		}

		per = min(per, sCC/orCC);
		if(it->first != 'n') {
			pernN = min(pernN, sCC/orCC);
		}

		f = false;
	}

	int rem = (pernN > 0 && (OrC['n'] - sC['n']%OrC['n']) == 1 && allP);
	cout << per+rem;

	return 0;
}

#include<bits/stdc++.h>
#include<string.h>
#include<stdlib.h>
using namespace std;
main()
{
    char s[105];
    static int x,y,i,j=0,a,b,c,d,k=0;
    gets(s);
    for(i=0;i<strlen(s);i++)
    {
        if(s[i]=='n')
        a++;
        else if(s[i]=='e')
            b++;
        else if(s[i]=='t')
            c++;
        else if(s[i]=='i')
            d++;
    }
    for(i=1;;i++)
    {
        if(i>1&&(a==2*i+1&&b>=3*i&&c>=i&&d>=i))
        {
            i++;break;
        }
        if(a<3*i||b<3*i||c<i||d<i)
            break;
    }
    cout<<i-1;
}