#include <bits/stdc++.h>
using namespace std;
int main() {
  string x;
  x.reserve(200000);
  cin >> x;
  int32_t Scount{0}, count{0};
  for (auto i{0}; i < x.size(); ++i) {
    if (x[i] == 'S') {
      ++Scount;
    } else {
      count += Scount-- > 0 ? 1 : 0;
    }
  }
  cout << x.size() - 2 * count << endl;
}
