#include <bits/stdc++.h>
using namespace std;
int slen(char *dat) {
  int i = 0;
  while (dat[i] != '\0') i++;
  return i;
}
int main() {
  int sc = 0;
  int count = 0;
  char dat[200001];
  cin >> dat;
  for (int i = 0; i < slen(dat); i++) {
    if (dat[i] == 'S') {
      sc++;
    } else {
      if (sc > 0)
        sc--;
      else
        count++;
    }
  }
  cout << (count + sc) << endl;
  return 0;
}
