mystr = raw_input()
s_count = 0
t_count = 0
pairs = 0
for x in mystr:
    if x == "S":
        s_count += 1
    else:
        if (t_count < s_count):
            pairs += 1
            t_count +=1
print len(mystr)-2*pairs