#include <bits/stdc++.h>
using namespace std;
string str, s;
int main() {
  cin >> str;
  s = "ST";
  int m, flag = 0, sum = 0, n = 2;
  while (flag == 0) {
    m = str.find(s);
    if (m < 0)
      flag = 1;
    else {
      str.erase(m, n);
      sum++;
    }
  }
  printf("%d", str.size());
  return 0;
}
