from itertools import groupby
x = [[i,len(list(j))] for i,j in groupby(input())]

ans = []
if x[0][0] == "T":
    ans.append(x[0][1])
if x[-1][0] == "S":
    ans.append(x[-1][1])
    
print(max(ans)*2)