import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String s = sc.next();
long c = 0;
long h = 0;
long n = 0;
for(int i = 0 ; i < s.length() ; i++) {
if(s.charAt(i) == 'C') {
c++;
} else if(s.charAt(i) == 'H') {
h += c;
} else if(s.charAt(i) == 'N') {
n += h;
}
}
System.out.println(n);
}
}