X = input()
N = len(X)
start = X.index("S")
end = N - X[::-1].index("T")
cnt_S = 0
cnt_T = 0
for x in X[start:end]:
    if x == "S":
        cnt_S += 1
    else:
        cnt_T += 1
print(start + N - end + abs(cnt_S - cnt_T))
