#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int l = s.length();
  int cs = 0;
  int ct = 0;
  int c = 0;
  for (int i = 0; i < l - 1; i++) {
    if (s[i] == 'S') {
      cs++;
      if (cs >= ct) {
        c++;
      }
    } else {
      ct++;
    }
  }
  cout << l - c * 2 << endl;
  return 0;
}
