x = input()
i = len(x)

def find(s, b):
    n = len(s)
    m = len(b)

    if n == m:
        if s == b:
            return 0
        else:
            return -1

    for i in range(n - m - 1):
        if s[i:i+m] == b:
            return i
    return -1


while True:
    p = find(x, 'ST')
    if p == -1:
        break
    p1 = p
    p2 = p+2
    n = p
    while True:
        if len(x) -1 > 0:
            
            if x[n-1] == 'S' and x[n+2] == 'T':
                n -= 1
                p1 -= 1
                p2 += 1
            else:
                break
    # print(x, p1, p2)
    x = x[:p1] + x[p2:]
    # print(x)
print(len(x))
