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