#include<bits/stdc++.h>
using namespace std;

int main(){
  string s; cin >> s;
  int N = s.size(), counter = 0, cS = 0;
  for( int i = 0; i < N; i++ ){
    if(s[i] == 'S') cS++;
    else{
      if(cS != 0) counter += 2, cS--;
    }
  }
  cout << N - counter << endl;
}