x = input()

def test(x):
    x2 = [i for i in x]
    while True:
        flag = True
        n = len(x2)
        for i in range(n - 1):
            if x2[i] == "S" and x2[i + 1] == "T":
                flag = False
                x2.pop(i)
                x2.pop(i)
                break
        if flag:
            break
    return len(x2)

print(test(x))

# def main(x): 
#     s_cnt = 0
#     t_cnt = 0
#     n = len(x)
#     ans = n
#     for i in range(n):
#         if i == 0:
#             if x[i] == "S":
#                 s_cnt += 1
#             continue
#         if x[i] == "S":
#             if x[i - 1] == "T":
#                 ans -= min(s_cnt, t_cnt) * 2
#                 s_cnt = 1
#                 t_cnt = 0
#             else:
#                 s_cnt += 1
#         else:
#             t_cnt += 1
#     ans -= min(s_cnt, t_cnt) * 2
#     # print(ans)
#     return ans

# for i in range(1 << 10):
#     bit = bin(i)[2:].zfill(10)
#     x = ""
#     for j in range(10):
#         if bit[j] == "1":
#             x += "S"
#         else:
#             x += "T"
#     ans_main = main(x)
#     ans_test = test(x)
#     if ans_main != ans_test:
#         print(x)
#         print(ans_main)
#         print(ans_test)
#         # print("error")
#         break
