#!/usr/bin/env python
# coding: utf-8

# In[12]:


X = input()


# In[15]:


mylist = X
while "ST" in mylist:
    if mylist == "ST":
        mylist = ""
    else:
        idx = X.index("ST")
        mylist = mylist[:idx] + mylist[idx+2:]
print(len(mylist))


# In[ ]:




