#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  reverse(s.begin(), s.end());
  int st = 0, t = 0;
  for (int i = 0; i < (int)s.size(); i++) {
    if (t == 0 && s[i] == 'S')
      continue;
    else
      t++;
    if (t >= 1 && s[i] == 'S') {
      t--;
      st++;
    }
  }
  cout << (s.size() - st * 2) << endl;
  return 0;
}
