X = str(input())

flag = True
s = 0
for i in range(len(X)):
  if flag:
    if X[i] == 'S':
      s = i
      break
      
flag = True
t = 0
for i in range(len(X)):
  if flag:
    if X[len(X)-i-1] == 'T':
      t = len(X)-i
      break
      
n = min(X[s:t].count('S'), X[s:t].count('T'))
ans = len(X) - 2*n
print(ans)