X = str(input())

tmorethans = 0
totalts = 0
Nagasa = len(X)

for i in range (0, len(X)+1):
	if 2*totalts == Nagasa:
		print(2*tmorethans)
		exit()
	elif X[i] == 'T':
		tmorethans+=1
		totalts+=1
	else:
		tmorethans-=1