package main

import (
	"fmt"
	"strings"
)

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

	size := 0
	for size != len(X) {
		size = len(X)
		X = strings.Replace(X, "ST", "", -1)
		// log.Println(X, size, len(X))
	}
	fmt.Println(len(X))
}
