#include <bits/stdc++.h>
using namespace std;
int main() {
  int size, ans, cou;
  cou = 0;
  string X;
  cin >> X;
  size = X.length();
  ans = size;
  for (int i = 0; i < size; i++) {
    if (X[i] == 'S') {
      cou++;
    }
    if (X[i] == 'T') {
      ans -= cou;
      cou = 0;
    }
  }
  cout << ans << endl;
}
