#include <bits/stdc++.h>
using namespace std;
int main() {
  int s, t, i, length, count;
  string N;
  s = 0;
  t = 0;
  count = 0;
  cin >> N;
  length = N.size();
  for (i = 0; i < length; i++) {
    if (N[i] == 'S') {
      s++;
      if (s - t >= 0) count++;
    } else {
      t++;
      if (s - t >= 0) count++;
    }
  }
  cout << length - 2 * count << "\n";
  return 0;
}
