s = input()
stop = 0
while stop == 0:
    ls = list(s)
    for i in range(len(ls)-1):
        if ls[i] == "S" and ls[i+1] == "T":
            ls[i], ls[i+1] = "", ""
    new_s = "".join(ls)
    if s == new_s:
        stop = 1
    else:
        s = new_s 
print(len(s))