#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1e9;
const long long INF = (long long)1e18;
const double eps = 1e-9;
const double pi = acos(-1.0);
string second;
stack<char> q;
int main() {
  cin >> second;
  for (int i = 0; i < (int)second.size(); ++i) {
    if (q.empty())
      q.push(second[i]);
    else {
      if (second[i] == 'S') {
        q.push(second[i]);
      } else {
        if (q.top() == 'S')
          q.pop();
        else
          q.push(second[i]);
      }
    }
  }
  printf("%d\n", (int)(int)q.size());
  return 0;
}
