#include <bits/stdc++.h>
using namespace std;
vector<char> v;
int main() {
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'S' || v.empty())
      v.push_back(s[i]);
    else
      v.pop_back();
  }
  cout << v.size();
  return 0;
}
