package main

import (
	"fmt"
	"math"
)

func main() {
	var (
		cnt, cntS float64
		X         string
	)
	fmt.Scan(&X)

	for _, v := range X {
		switch v {
		case 'S':
			cntS++
		case 'T':
			if cntS == 0 {
				cnt++
			}
			cntS = math.Max(0, cntS-1)
		}
	}
	println(int(cnt + cntS))
}
