#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
typedef long long ll;
typedef pair<int64_t,int64_t> pll;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define ALL(a) begin(a),end(a)
#define sz(s) (s).size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second

void solve()
{   
    stack<char>s;
    char x;
    while(cin>>x){
        if(x=='T'){if(s.empty()||s.top()=='T')s.push('T');else if(s.top()=='S')s.pop();}
        else(x=='S')s.push('S');
    }cout<<s.size()<<endl;
}


int main()
{ 
    cin.tie(0);
	ios::sync_with_stdio(false);
    solve();
    return 0;
}