#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int k = 0, sn;
  for (auto c : s) {
    if (c == 'S') {
      ++sn;
    } else {
      if (sn > 0) {
        --sn;
        k += 2;
      }
    }
  }
  cout << s.length() - k << endl;
  return 0;
}
