CF#230 A题Nineteen

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.

Sample test(s)
input
nniinneetteeeenn
output
2
input
nneteenabcnneteenabcnneteenabcnneteenabcnneteenabcii
output
2
input
nineteenineteen
output
2
#include <stdio.h>
#include <string.h>
char s[102];
int main()
{
    int i, j, x=100000, a[4]={0}, k;
    scanf("%s",s);
    k=strlen(s);
    for(i=0;i<k;i++)
    {
        if(s[i]=='n')
            a[0]++;
            else if(s[i]=='i')
                a[1]++;
            else if(s[i]=='e')
                a[2]++;
            else if(s[i]=='t')
                a[3]++;
    }
    a[0]=(a[0]-1)/2;
    a[1]=a[1];
    a[2]=a[2]/3;
    a[3]=a[3];
    for(i=0;i<4;i++)
    {
        if(x>a[i])
            x=a[i];
    }
    printf("%d\n",x);
    return 0;
}


你可能感兴趣的:(编程,C语言)