s = input()
cnt = 0
while cnt < 100000:
    sp = s.split('ST', 1)
    if len(sp) > 1:
        cntlen = 0
        for i in range(min(len(sp[0]), len(sp[1]))):
            if sp[0][-1-i] == "S" and sp[1][i] == "T":
                cntlen += 1
            else:
                break
        s = sp[0][:len(sp[0])-0] + sp[1][cntlen:]
        cnt += 1 + cntlen
    else:
        break
print(len(s))