#include <bits/stdc++.h>
using namespace std;
int main() {
  string x;
  cin >> x;
  bool b = 1;
  bool flag = 1;
  int i = 0;
  while (true) {
    if (i == x.size() - 1) {
      i = 0;
      b = 1;
      if (b) {
        break;
      }
      continue;
    }
    if (x[i] == 'S' && x[i + 1] == 'T') {
      x.erase(i, 2);
      b = 0;
      i = 0;
    }
    i++;
  }
  if (x[i] == 'S' && x[i + 1] == 'T' && x.size() == 2) {
    cout << "0";
  } else {
    cout << x.size();
  }
}
