#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  string x;
  cin >> x;
  for (int i = 0; i < x.size(); i++) {
    if (x[i] == 'S' && x[i + 1] == 'T') {
      x.erase(i, 2);
      i = -1;
    }
  }
  cout << x.size() << endl;
}
