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

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


print(solve2())