#include <fstream>
#include <string>
using namespace std;

int main()
{
    fstream input("MK.inp");
    ofstream output("MK.out");

    string a;
    long long temp = 0;
    getline(input, a);
    long long total = 0;
    for (int i = 0; i < a.length(); i++)
    {
        if (a[i] == 'C')
        {
            temp++;
            total += temp;
        }
        if (a[i] == 'N')
        {
            temp = 0;
        }
    }
    output << total;
    input.close();
    output.close();
    return 0;
}
