#25531: c++解答


yp10952161@yphs.tp.edu.tw (無)


#include <bits/stdc++.h>

using namespace std;

int main()

    ios::sync_with_stdio(false); 

    string s; 

    while(cin>>s)

    {   

        int p=0,ans=0; 

        for(int i=0; i<s.length(); i++) 

            if(s[i]=='y') {ans+=abs(i-p); p+=3;} 

        cout<<ans<<'\n';

    }

}