X = str(input())

count= 0
count2 = 0
Nagasa = len(X)

for i in range (0, len(X)):
	if 2*count2 == Nagasa:
		print(2*count)
		exit()
	if X[i] == 'T':
		count+=1
		count2+=1
	if X[i] == 'S':
		count-=1

print(0)