#include <bits/stdc++.h>
using namespace std;
int main() {
  string x;
  cin >> x;
  int iter = 1;
  while (true) {
    if (iter == (int)x.length()) break;
    if (x[iter - 1] == 'S' && x[iter] == 'T') {
      x.erase(iter - 1, 2);
      iter = 0;
    } else {
      iter++;
    }
  }
  cout << x.size();
}
