#include using namespace std; using ll = long long; ll a[200005]; int main(){ string s; cin >> s; vector t; for(int i = 0; i < s.size(); i++){ if(s[i]=='S') t.push_back(0); if(s[i]=='i' && s[i+1]=='n' && s[i+2]=='g') t.push_back(1); } int n = t.size(); int cnt = 0; for(int i = n-1; i>=0; i--){ if(t[i]==1) cnt++; a[i] = cnt; } ll ans = 0; for(int i = 0; i < n; i++){ if(t[i]==0) ans += a[i]; } cout << ans << endl; return 0; }