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

string X;

int main(){
  cin >> X;
  int cnt = 0;
  int px = 0;
  for(char c : X ){
    if( px == 0 && c == 'T' ) cnt++;
    else if( c == 'S' ) px++;
    else  px--;
  }
  cout << cnt + px << endl;
}
