S = input()
N = len(S)
t_cnt = 0
s_cnt = 0

for i in range(N):
    if S[i] == 'T':
        t_cnt += 1
    else:
        break

for i in range(N):
    if S[N-1-i] == 'S':
        s_cnt += 1
    else:
        break

print(max(t_cnt,s_cnt) * 2)