#include <bits/stdc++.h>
using namespace std;
int main() {
  string X;
  cin >> X;
  int c_s = 0;
  int c_t = 0;
  int del = 0;
  for (int i = 0; i < X.size(); i++) {
    if (X[i] == 'S') {
      if (c_t > 0) {
        del += 2 * min(c_s, c_t);
        c_s = 0;
        c_t = 0;
      }
      c_s++;
    } else {
      c_t++;
    }
  }
  if (c_t > 0) {
    del += 2 * min(c_s, c_t);
  }
  printf("%d\n", X.size() - del);
  return 0;
}
