#include <bits/stdc++.h>
using namespace std;
int main() {
  stack<char> x;
  char a, ex = 'T';
  do {
    cin >> a;
    if (a == '\n') break;
    x.push(a);
    if (ex == 'S' && x.top() == 'T') {
      x.pop();
      x.pop();
    }
    ex = x.top();
  } while (1);
  cout << x.size() << endl;
  return 0;
}
