def ST_string():
	x = str(raw_input())
	len_changed = True
	l2 = 0
	while len_changed:
		l1 = len(x)
		x = x.replace("ST", "", 1)
		l2 = len(x)
		if l1==l2:
			len_changed = False
	print l2

if __name__ == "__main__":
	ST_string()