#include using namespace std; using ll = long long; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); string s; cin >> s; vector vs,vi; size_t i{ 0 }, p; while ((p = s.find("S", i)) != string::npos) { vs.push_back(p); i = p + 1; } i = 1; while ((p = s.find("ing", i)) != string::npos) { vi.push_back(p); i = p + 3; } ll res{ 0 }; for (size_t i = 0; i < vs.size(); ++i) { auto it = upper_bound(vi.begin(), vi.end(), vs[i]); if (it != vi.end()) res += vi.end() - it; } cout << res << "\n"; return 0; }