X = input()
def erase(string,word):
    for i in range(10**5):
        note = string
        string = string.replace(word,"")
        if note == string:
            break
    return string
for e in ["SSSSTTTT","SSSTTT","SSTT","ST"]:
    X = erase(X,e)
print(len(X))