x = input()
i = len(x)
cnt = 0


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:
        cnt += 1
    else:
        break
    
    n = p
    while True:
        if len(x) -1 > 0:
            
            if x[n-1] == 'S':
                cnt += 1
                n -= 1
            else:
                break
    x = x[:p] + x[p+2:]
print(len(x))
