X = input()
countS = 0
countT = 0
for i in range(len(X)):
    if X[i] == "T":
        countT += 1
    else:
        countS += 1
    if countT == len(X)/2:
        print(2*(countT-countS))
        exit()
    if countS == len(X)/2:
        if i == len(X)-2:
            print(0)
        else:
            print(2*(countS-countT))
        exit()
