import sys

x = raw_input()

x = [i for i in x]

while(True):
    end = True
    for i in range(0,len(x)-1):
#        print len(x),i,x[i],x[i+1],end
        if(x[i]=='S' and x[i+1]=='T'):
            del x[i+1]
            del x[i]
            end = False
#            print x
        if end is False:
            break

    if end:
        print len(x)
        sys.exit()