#include "bits/stdc++.h" using namespace std; // コンテスト中のみ //#define int long long #define ll long long #define rep(i,n) for(int i = 0; i < (n); i++) #define P pair #define ld long double ll INF = (1LL << 60); int MOD = 1000000007; string s; ll cnt = 0; ll ans = 0; signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); cin >> s; rep(i, s.size()) { if (s[i] == 'S') { cnt++; } if (i + 2 < s.size() && s.substr(i, 3) == "ing") { ans += cnt; } } cout << ans << endl; return 0; }