X = raw_input()

num_s = 0
num_t = 0
pre = ""
ans = 0
for a in X:
    if a == "S":
        if pre == "T":
            ans += min(num_s, num_t)
            num_s = 0
            num_t = 0
        num_s += 1
    elif a == "T":
        num_t += 1
    pre = a
ans += min(num_s, num_t)
print len(X) - 2*ans