#include <bits/stdc++.h>
using namespace std;
const long long INF = 10000000000;
int main() {
  string Q;
  cin >> Q;
  int a, b = 0;
  for (int i = 0; i < Q.size(); i++) {
    if (Q[i] == 'T') a = i;
  }
  a++;
  for (int i = 0; i < a; i++) {
    if (Q[i] == 'S') b++;
  }
  if (a - b > b)
    cout << a - 2 * b + Q.size() - a << endl;
  else if (a - b == b)
    cout << Q.size() - a << endl;
  else
    cout << a - 2 * (a - b) + Q.size() - a << endl;
  return 0;
}
