import numpy as np
import functools
import math
import scipy
import fractions
import itertools

def solve():
    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

    return 0
 
if __name__ == "__main__":
    solve()
