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