#include #include #include #include using namespace std; int main(void) { string s; cin >> s; vector idxs; for (int i = 0; i < s.size()-2; ++i) { if (s.substr(i, 3) == "ing") idxs.push_back(i); } int ans = 0; for (int i = 0; i < s.size(); ++i) { if (s[i] == 'S') { int idx = lower_bound(idxs.begin(), idxs.end(), i) - idxs.begin(); ans += (idxs.size() - idx); } } cout << ans << endl; }