package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	const maxWord = (1 << 30)
	buf := []byte{}
	sc.Buffer(buf, maxWord)
	sc.Split(bufio.ScanWords)
}

func input() string {
	sc.Scan()
	return sc.Text()
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func main() {
	s := input()
	n := len(s)
	left := 0
	for i := 0; i < n; i++ {
		if s[i] == 'T' {
			left++
		} else {
			break
		}
	}

	right := 0
	for i := n - 1; i >= 0; i-- {
		if s[i] == 'S' {
			right++
		} else {
			break
		}
	}
	fmt.Println(max(left, right) * 2)
}
