X = input()
N = len(X)
t = 0
flag = False
for i in range(N):
    if X[-1-i] == 'T':
        flag = True
    if flag:
        if X[-1-i] == 'T':
            t += 1
        else:
            t -= 1
print(2*t)