x = list(input())
box = []

for i in range(len(x)):
    if x[i] == "S": box.append(x[i])
    else:
        if len(box) == 0 or box[-1] == "S":
            box.append(x[i])
        else: box.pop(-1)
print(len(box))