#include <bits/stdc++.h>
using namespace std;
int main() {
  string x;
  cin >> x;
  int scount = 0;
  int tcount = 0;
  int ans = x.size();
  for (int i = 0; i < x.size(); i++) {
    if (x.at(i) == 'S') {
      scount++;
    } else {
      tcount++;
    }
    if (scount > tcount) {
      ans -= 2;
      scount--;
    }
  }
  cout << ans;
}
