#include <stdio.h>

int main()
{
    char s[8000] = { 0 };
    scanf("%s", s);
    char* p = s;
    long long c = 0;
    long long ch = 0;
    long long chn = 0;
    while (*p)
    {
        if ('C' == *p)
        {
            c++;
        }
        else if ('H' == *p)
        {
            ch += c;
        }
        else if ('N' == *p)
        {
            chn += ch;
        }
        p++;
    }
    printf("%lld\n", chn);

    return 0;
}