#include <bits/stdc++.h>
using namespace std;
int main() {
  string str;
  cin >> str;
  int n = str.size();
  while (n != 0) {
    int p = str.find("ST");
    if (p == -1) break;
    str.erase(p, 2);
    n = str.size();
  }
  n = str.size();
  cout << n;
}
