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

int main(){
  string s; cin >> s;
  int ans = s.size();
  int ss = 0;
  for(char i : s){
    if(i=='S') ss++;
    else if(ss){
      ss--;
      ans -= 2;
    }
  }
  cout << ans;
}
