X = input()
cnt = 0
for i in range(len(X)):
    if X[i] == 'T':
        cnt += 1
    else:
        break


X2 = X[::-1]
cnt2 = 0
for i in range(len(X2)):
    if X2[i] == 'S':
        cnt2 += 1
    else:
        break

print(2*max(cnt, cnt2))
