X = input()
for i in range(len(X)):
    if X[i] == "S":
        count_T = X[i:].count("T")
        break
for i in range(len(X)-1,-1,-1):
    if X[i] == "T":
        count_S = X[:i+1].count("S")
        break
pair = min(count_T,count_S)
ans = len(X) - 2 * pair
print(ans)