#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fr first
#define sc second
using namespace std;
typedef long long ll;
const long long llnrm=LLONG_MAX;
const int nrm=INT_MAX;
const int nrn=INT_MIN;
const int nmax=1e5+5;
const int mod=1e9+7;
const long long llim=1e18;
const int lim=1e8;
int ans,a[101];
string s;
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
    // freopen("solution.in","r",stdin);
	//freopen("solution.out","w",stdout);
	cin>>s;
	len=s.size();
    for(int i=0;i<s.size()-1;i++)
    {
        if(s[i]=='S' && s[i+1]=='T')
        {
            s.erase(i,2);
            i-=2;
            len-=2;
        }
  }
  cout<<len<<endl;
  return 0;
}

