s = list(str(input()))
while True:
    cns = len(s)
    cnt = 0
    for i in range(cns):
        try:
            a = s[i]
            b = s[i+1]
            if a == "S" and b == "T":
                del s[i:i+2]
                cnt -= 1
        except:
            pass
    if cnt == 0:
        print(len(s))
        exit()
