x = input()
le = len(x)
while True:
    bit = 0
    for i in range(le-1):
        if x[i:i+2] == "ST":
            x = x[0:i]+x[i+2:le]
            bit = 1
            break
    if bit == 0:
        print(len(x))
        break