_x = input()
x = []
for i in _x:
    x.append(i)
count = 0
i = 0
while i < len(x):
    # print("i:{} x:{}".format(i, x))
    if i < len(x) - 1 and x[i] == "S" and x[i + 1] == "T":
        del x[i]
        del x[i]
        if i > 0:
            i -= 1
        continue
    else:
        count += 1
        i += 1
print(len(x))
