#include <bits/stdc++.h>
using namespace std;
vector<char> A;
int ans() {
  int i = 0;
  vector<char>::iterator it = A.begin(), it2 = A.begin();
  int p = A.size() - 1;
  while (i < p) {
    if (A[i] == 'S' && A[i + 1] == 'T') {
      advance(it, i);
      advance(it2, i + 2);
      A.erase(it, it2);
      it = A.begin();
      it2 = A.begin();
      i = 0;
      p = A.size() - 1;
    } else {
      i++;
      p = A.size() - 1;
    }
  }
  return A.size();
}
int main() {
  string d;
  cin >> d;
  A.clear();
  A.resize(d.size());
  for (int k = 0; k < d.size(); k++) {
    A[k] = d[k];
  }
  cout << ans() << endl;
}
