#include <iostream>
#include <stack>
#include <string>
using namespace std;

void PRF(string T, int f[]){
    int m = T.length();
    int k;
    f[0] = -1;
    for(int i = 1; i<m; i++){
        k=f[i-1];
        while(k>=0){
            if(T[k] == T[i-1]){
                break;
            } else{
                k = f[k];
            }
        }
        f[i] = k+1;
    }
}

void KMP(string T, string String){
	bool fnd = false;

    int Tl = T.length();
    int Sl = String.length();
    int tmp[Tl];

    PRF(T, tmp);
    int i=0;
    int k=0;
    while(i<Sl){
        if(k==-1){
            i++;
            k=0;
        } 
        
        else if(String[i]==T[k]){
            i++;
            k++;
            if(k==Tl){
            	fnd=true;
				for(int j=i; i<i-Tl; i--){
 					String.pop();
 				}
            }
        } else{
            k = tmp[k];
        }
    }
    while(fnd){
 		KMP(T, String);
    }
    cout<<String.length();

}
int main()
{
string String, T;

cin>>String;

T="ST";
KMP(T, String);
}