#include <bits/stdc++.h>
using namespace std;
string c;
int main() {
  std::ios::sync_with_stdio(false);
  cin >> c;
  int i = 0;
  int pos = 0;
  while ((pos = c.find("ST")) != -1) {
    c.erase(pos, 2);
  }
  cout << c.size();
  return 0;
}
