# include <iostream>
# include <vector>
# include <algorithm>
using namespace std;

# define ll long long

int main(){
 
  string S;
  cin >> S;
  vector<char> stack;
  
  for(int i=0; i<S.size(); i++){
    if(S[i] == 'S') stack.push_back(s[i]);
    else {
      if(stack.empty()) stack.push_back(s[i]);
      else stack.pop_back();
    }
  }
  
  cout << stack.size() << endl;
  return 0;
} 

