package main

import "fmt"

func diff(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func main() {
	var x string
	fmt.Scan(&x)

	leftT := 0
	tmp1 := -1
	for i := 0; i < len(x); i++ {
		if x[i] == 'T' {
			leftT++
		} else {
			tmp1 = i
			break
		}
	}
	x = x[tmp1:]

	rightS := 0
	tmp2 := -1
	for i := len(x) - 1; i >= 0; i-- {
		if x[i] == 'S' {
			rightS++
		} else {
			tmp2 = i + 1
			break
		}
	}
	x = x[:tmp2]

	ans := leftT + rightS + diff(leftT, rightS)
	fmt.Println(ans)
}
