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