#include <bits/stdc++.h>
using namespace std;
multimap<int, int> ship;
int n, m, cnt = 0;
bool clear = false;
vector<int> buckets(100004, 0);
int main(int argc, char const* argv[]) {
  string x;
  cin >> x;
  n = x.size();
  while (!clear) {
    clear = true;
    for (int i = 0; i < n - 1; i++) {
      if (x[i] == 'S' && x[i + 1] == 'T') {
        x.erase(x.begin() + i, x.begin() + (i + 2));
        n = x.size();
        clear = false;
      }
    }
  }
  cout << n << endl;
  return 0;
}
