#include <bits/stdc++.h>
using namespace std;
int main() {
  string a;
  cin >> a;
  stack<char> s;
  int b = a.size();
  for (int i = 0; i < b; i++) {
    if (a.at(i) == 'S')
      s.push(a.at(i));
    else if (a.at(i) == 'T' && i == 0)
      s.push(a.at(i));
    else if (a.at(i) == 'T' && s.top() == 'T')
      s.push(a.at(i));
    else
      s.pop();
  }
  cout << s.size();
}
