package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

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

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	s := next()
	n := len(s)

	// 一番右のTの場所
	var rightTIndex int
	for rightTIndex = n - 1; rightTIndex >= 0 && s[rightTIndex] == 'S'; rightTIndex-- {
	}

	// 一番右のTより左にあるSの個数
	cntS := 0
	for i := 0; i < rightTIndex; i++ {
		if s[i] == 'S' {
			cntS++
		}
	}

	puts(n - cntS*2)
}
