x = input()
ans = len(x)


def do(i, j):
    global ans
    if x[i] == 'S' and x[j] == 'T':
        ans -= 2
        if i > 0 and j < len(x) - 1:
            do(i-1, j+1)
    if j - i == 1 and j < len(x) - 1:
        do(i+1, j+1)


do(0, 1)
print(ans)
