import re
X = raw_input()
iter = 100000
pat = re.compile('(ST)')

for i in xrange(iter):
    s =	pat.search(X)
    if len(X) == 0:
	break
    if s is	not None:
    	X =	X.replace('ST','')
    else:
	break
print len(X)