X = list(input())
N = len(X)
NHALF = N // 2

def solve():
    nt, rs = 0, 0
    for i in range(N):
        if nt == NHALF:
            break
        if X[i] == 'T':
            nt += 1
        else:
            rs += 1
    ns, rt = 0, 0
    for i in range(N-1, -1, -1):
        if ns == NHALF:
            break
        if X[i] == 'S':
            ns += 1
        else:
            rt += 1
    return N - 2 * min(rs, rt)


print(solve())