codeforces--2014/2/20--A. Nineteen

来源:互联网 发布:遵义广电网络客服电话 编辑:程序博客网 时间:2024/05/16 08:06
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 strings 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 strings doesn't exceed 100.

Output

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

Sample test(s)
Input
nniinneetteeeenn
Output
2
Input
nneteenabcnneteenabcnneteenabcnneteenabcnneteenabcii
Output
2
Input
nineteenineteen
Output
2
统计字母的个数,注意n是有重叠的   
#include <stdio.h>#include <string.h>int main(){    int i , j , li , num_n = 0 , num_i = 0 , num_t = 0 , num_e = 0 ;    char s[110] ;    scanf("%s", s);    li = strlen(s);    for(i = 0 ; i < li  ; i++)    {        if(s[i] =='n')num_n++;        else if(s[i]=='i')num_i++;        else if(s[i] == 't')num_t++;        else if(s[i] == 'e')            num_e++;    }    num_e = num_e / 3 ;    li = num_e;    if(num_i < li)        li = num_i ;    if(num_t < li)        li = num_t ;    if(li*3 - li + 1 > num_n)        li = (num_n-1)/2 ;    printf("%d\n", li);}


0 0
原创粉丝点击