import sys

def main():
    N = input().strip()
    while True:
        ngram_list=[]
        #round 1
        for i in range(len(N)-1):
            ngram_list.append(N[i:i+2])
        #round 2
        if "ST" in ngram_list:
            idx=ngram_list.index("ST")
            if idx+2 > len(N):
                N = N[:idx]
            else:
                N=N[:idx]+N[idx+2:]
        else:
            return print(len(N))


if __name__ == "__main__":
    main()