#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vll vector<ll>
#define vbool vector<bool>
#define INF 100000000

bool solve(int i,int m);

int main(){
  int scount = 0;
  int tcount = 0;
  string s;
  cin >> s;
  int ss = s.size();
  int ans = ss;
  rep(i,ss){
    if(s[i] == 'T'){
      tcount++;
      while(tcount > 0 && scount > 0){
        ans -= 2;
        tcount--;
        scount--;
      }
    }
    if(s[i] == 'S'){
      scount++;
      tcount = 0;
  }
  cout << ans << endl;
}


