#include <bits/stdc++.h>
using namespace std;
string s;
int a;
int main() {
  cin >> s;
  while (s.find("ST") < s.size()) {
    a = s.find("ST");
    s.erase(s.begin() + a);
    s.erase(s.begin() + a);
  }
  cout << s.size();
  return 0;
}
