#include <bits/stdc++.h>
using namespace std;
void delet(string &str, string &substr) {
  int k, l = substr.length();
  while (1) {
    if ((k = str.find(substr)) < 0) break;
    str.erase(k, l);
  }
  cout << str.length();
}
int main() {
  string a, b;
  cin >> a;
  b = "ST";
  delet(a, b);
  return 0;
}
