X = input().rstrip() + "#"
s0 = X[0]
P = []
cnt = 1
for s in X[1:]:
    if s==s0:
        cnt += 1
    else:
        P.append(cnt)
        cnt = 1
    s0 = s
res = 0
if X[0] == "T":
    res = P[0]*2
if X[-2] == "S":
    res = max(P[-1]*2, res)
print(res)