#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, n, d = 0;
  string x;
  cin >> x;
  n = x.size();
  while (1) {
    for (i = 0; i < n - 1 - d; i++) {
      if (x[i] == 'S') {
        if (x[i + 1] == 'T') {
          x.erase(i, 2);
          d += 2;
          break;
        }
      }
    }
    if (i == n - 1 - d || n - d == 0) {
      break;
    }
  }
  n = x.size();
  cout << n << endl;
  return 0;
}
