#include <bits/stdc++.h>
using namespace std;
int main() {
  int erase_num = 0;
  string str;
  cin >> str;
  while (str.find("ST", erase_num) != -1) {
    erase_num += 2;
  }
  cout << str.length() - erase_num << endl;
}
