#include <bits/stdc++.h>
using namespace std;
template <typename T>
void remove(std::vector<T>& vector, unsigned int index) {
  vector.erase(vector.begin() + index);
}
int main() {
  string s;
  cin >> s;
  int cont = 0;
  for (int i = 0; i <= s.size() - 1; i++) {
    if (s[i] == 'S')
      if (s[i + 1] == 'T') cont++, i++;
  }
  cout << s.size() - 2 * cont << '\n';
}
