X = str(input())
left_t_index = 0
right_s_index = 0
for i in range(len(X)):
    if X[i] == "S":  # 最も左にあるSの位置が分かる
        left_t_index = i
        break
for i in reversed(range(len(X))):
    if X[i] == "T":  # 最も右にあるTの位置が分かる
        right_s_index = i
        break
s_count = 0
t_count = 0
# print(left_t_index)
# print(right_s_index)
for i in range(left_t_index, right_s_index+1):
    if X[i] == "S":
        s_count += 1
    elif X[i] == "T":
        t_count += 1

print(len(X)-2*min(s_count, t_count))
