#include <bits/stdc++.h>
using namespace std;
string fun(string a) {
  bool update = false;
  for (int i = 0; i < a.length() - 1; i++) {
    if (a[i] == 'S' && a[i + 1] == 'T') {
      a.erase(i, 2);
      update = true;
      break;
    }
  }
  if (a.length() == 0) return "empty";
  if (update) return fun(a);
  return a;
}
int main() {
  string a;
  cin >> a;
  a = fun(a);
  if (a == "empty")
    cout << "0" << endl;
  else
    cout << a.length() << endl;
  return 0;
}
