import sys
X = list(sys.stdin.readline().strip())
N = len(X)
NHALF = N // 2

def solve2():
    ns = 0
    nt = 0
    i = 0
    while nt < NHALF:
        if X[i] == 'T':
            nt += 1
            i += 1
        else:
            ns += 1
            i += 1
    return N - 2*ns


print(solve2())