#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007;
int main() {
  string s;
  cin >> s;
  int n = s.size();
  int cnt = 0;
  for (int i = n / 2; i < n; ++i) {
    auto sub = s.substr(i, 1);
    if (sub == "S") {
      ++cnt;
    } else {
      if (cnt > 0) --cnt;
    }
  }
  cout << 2 * cnt << endl;
  return 0;
}
