# A - STring

N = 100000
X = input()
T_head = S_tail = 0

for i in range(N):
    if X[i]=='S':
        break
    T_head += 1

for i in range(N):
    if X[len(X)-i-1]=='T':
        break
    S_tail += 1

print(2*max(T_head, S_tail))