import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); char[] arr = sc.next().replaceAll("ing", "!").toCharArray(); long ans = 0; long sCount = 0; for (char c : arr) { if (c == 'S') { sCount++; } else if (c == '!') { ans += sCount; } } System.out.println(ans); } }