#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  while (1) {
    int64_t x = s.find("ST");
    if (x == string::npos)
      break;
    else
      s.erase(x, 2);
  }
  printf("%lld", s.size());
}
