X = input()

idx = None
for i in range(len(X) - 1, -1, -1):
    if X[i] == "T":
        idx = i
        break

n_s = X[: idx + 1].count("S")
n_t = X[: idx + 1].count("T")
ans = len(X) - 2 * min(n_s, n_t)
print(ans)
