X = input().strip()
N = len(X)
inds = -1
indt = N
for i in range(N):
    if X[i]=="S":
        inds = i
        break
for i in range(N-1,-1,-1):
    if X[i]=="T":
        indt = i
        break
print(2*max(inds,N-1-indt))