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":
            l, r = i, i + 1
            stop2 = 0
            while stop2 == 0:
                ls[l], ls[r] = "", ""
                l, r = l - 1, r + 1
                if ls[l] != "S" or ls[r] != "T":
                    stop2 = 1


    new_s = "".join(ls)
    if s == new_s:
        stop = 1
    else:
        s = new_s 
print(len(s))