#include <bits/stdc++.h>
using namespace std;
int main() {
  string n;
  cin >> n;
  long long f = n.length();
  long long res = f;
  for (long long i = 0; i < f; i++) {
    if (n[i] == 'T' && n[i - 1] == 'S') {
      long long cntr = 2;
      long long flag = 0;
      long long a = i;
      long long b = i - 1;
      while (flag == 0) {
        if (n[a + 1] == 'T' && n[b - 1] == 'S' && b - 1 >= 0 && a + 1 < f) {
          cntr = cntr + 2;
          a++;
          b--;
        } else {
          flag = 1;
        }
      }
      res = res - cntr;
    }
  }
  cout << res << endl;
  return 0;
}
