using System;
class A {
	static void Main() {

		var s = Console.ReadLine() + "A";
		for(int i = s.Length-1;i >= 0;i--) {
			if(s[i] == 'S' && s[i + 1] == 'T') {
				s = s.Remove(i,2);
			}
		}
		Console.WriteLine(s.Length-1);
	}
}