/* -*- coding: utf-8 -*- * * 1159.cc: No.1159 Sashiming String - yukicoder */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; /* constant */ const int MAX_N = 200000; /* typedef */ typedef long long ll; /* global variables */ char s[MAX_N + 4]; int ss[MAX_N], gs[MAX_N]; /* subroutines */ /* main */ int main() { scanf("%s", s); int n = strlen(s); int sn = 0, gn = 0; for (int i = 0; i < n; i++) { if (s[i] == 'S') ss[sn++] = i; else if (i + 2 < n && s[i] == 'i' && s[i + 1] == 'n' && s[i + 2] == 'g') gs[gn++] = i; } //printf("sn=%d, gn=%d\n", sn, gn); ll sum = 0; for (int i = 0; i < sn; i++) { int k = upper_bound(gs, gs + gn, ss[i]) - gs; sum += gn - k; } printf("%lld\n", sum); return 0; }