#include <stdio.h>
int main()
{
	char str[100000] = { 0 };
	scanf("%s", str);
	char *p = str;
	long long int c = 0, ch = 0, chn = 0;
	while (*p)
	{
		if (*p == 'C')
		{
			c++;
		}
		else if (*p == 'H')
		{
			ch += c;
		}
		else if (*p == 'N')
		{
			chn += ch;
		}
		p++;
	}
	printf("%lld", chn);
}