#include <bits/stdc++.h>
using namespace std;
int main(void) {
  string x;
  cin >> x;
  int ans = x.size();
  int bef = 0;
  for (int i = 0; i < (x.size() - 1); i++) {
    if (x[i] == 'S' && x[i + 1] == 'T') {
      int a = i;
      int b = i + 1;
      while (x[a] == 'S' && x[b] == 'T' && a >= bef && b <= x.size() - 1) {
        a--;
        b++;
        ans -= 2;
      }
      i = b - 1;
      bef = b;
    }
  }
  cout << ans << endl;
  return 0;
}
