Algorithm


A. Nineteen
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

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

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

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

Input

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

Output

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

Examples
input
Copy
nniinneetteeeenn
output
Copy
2
input
Copy
nneteenabcnneteenabcnneteenabcnneteenabcnneteenabcii
output
Copy
2
input
Copy
nineteenineteen
output
Copy
2



 

Code Examples

#1 Code Example with C++ Programming

Code - C++ Programming

#include <iostream>
#include <string>

using namespace std;

int main() {
	string s, res = "";
	int c = 0, x;

	cin >> s;
	x = s.length();

	for (int i = 0; i < x; i++) {
		if (s.find('n') < x) {
			res += 'n';
			s[s.find('n')] = ' ';
		}
		else {
			break;
		}

		if (s.find('i') < x) {
			res += 'i';
			s[s.find('i')] = ' ';
		}
		else {
			break;
		}

		if (s.find('n') < x) {
			res += 'n';
			s[s.find('n')] = ' ';
		}
		else {
			break;
		}

		if (s.find('e') < x) {
			res += 'e';
			s[s.find('e')] = ' ';
		}
		else {
			break;
		}


		if (s.find('t') < x) {
			res += 't';
			s[s.find('t')] = ' ';
		}
		else {
			break;
		}

		if (s.find('e') < x) {
			res += 'e';
			s[s.find('e')] = ' ';
		}
		else {
			break;
		}

		if (s.find('e') < x) {
			res += 'e';
			s[s.find('e')] = ' ';
		}
		else {
			break;
		}
	}

	while (res.length() > 1) {
		if(res.substr(0, 8) == "nineteen")
			c++;

		res.erase(0, 7);
	}

	cout << c << endl;

	return 0;
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
nniinneetteeeenn

Output

x
+
cmd
2
Advertisements

Demonstration


Codeforces Solution-Nineteen-Solution in C, C++, Java, Python

Previous
Codeforces solution 1080-B-B. Margarite and the best present codeforces solution
Next
CodeChef solution DETSCORE - Determine the Score CodeChef solution C,C+