S = input()
a = S.count('S')
b = S.count('T')
c = 0
for s in S:
  if s == 'T':
    c += 1
  else:
    break
d = 0
for s in S[::-1]:
  if s == 'S':
    d += 1
  else:
    break
c + d + abs(a-d - (b-c))