#include <bits/stdc++.h>
using namespace std;
using IntType = long long;
int main() {
  string line;
  cin >> line;
  IntType len = line.length();
  IntType i, j;
  for (i = 0; line[i] == 'T' && i < len; i++)
    ;
  for (j = len - 1; line[j] == 'S' && 0 <= j; j--)
    ;
  IntType k = min(i, j);
  cout << len - (2 * k) << endl;
  cerr << "hoge" << endl;
  return 0;
}
