← Home
```go
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	reader := bufio.NewReader(os.Stdin)
	line, _ := reader.ReadString('\n')

	countM := 0
	time := 0

	for _, ch := range line {
		if ch == 'M' {
			countM++
		} else if ch == 'F' {
			if countM > 0 {
				if countM > time+1 {
					time = countM
				} else {
					time = time + 1
				}
			}
		}
	}

	fmt.Println(time)
}
```