s = input()
cnt = 0
while cnt < 100000:
    n = len(s)
    s = ''.join(s.split('SSSSSSSSSTTTTTTTTTT'))
    if len(s) != n:
        cnt += (len(s) - n) // 2
    n = len(s)
    s = ''.join(s.split('ST'))
    if len(s) != n:
        cnt += (len(s) - n) // 2
    else:
        break
print(len(s))