# -*- coding: utf-8 -*-
#
# A - STring
#
import string
# input
x_before = input()
x_after = ''
translator=str.maketrans('','','ST')
# calc
while True:
  x_after = x_before.translate(translator)
  if len(x_before) == len(x_after):
    break
  x_before = x_after
# output
print(len(x_after))