#include <bits/stdc++.h>
using namespace std;
const long long INF = 1000000000ll;
const long long MOD = 1000000007ll;
const double EPS = 1e-8;
int main(void) {
  string x;
  cin >> x;
  for (int i = 0; i < x.size() - 1; i++) {
    if (x[i] == 'S' && x[i + 1] == 'T') {
      x = x.substr(0, i) + x.substr(i + 2);
      i -= 2;
      if (i < 0) i = -1;
      if (x.empty()) break;
    }
  }
  if (x.empty()) {
    cout << '0' << endl;
  } else {
    cout << x.size() << endl;
  }
  return 0;
}
