#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  long long int even = 0, odd = 0;
  long long int count = 0;
  string T = "ST";
  cin >> S;
  long long int l = S.length();
  for (int i = 0; i < l; i++) {
    if (S[i] == T[0]) {
      even++;
    }
  }
  for (int i = 0; i < l; i++) {
    if (S[i] == T[1]) {
      odd++;
    }
  }
  if (l % 2 == 0 && even == l / 2 && odd == l / 2 && l >= 2) {
    for (int i = l; i > 0; i--) {
      if (S[i] == T[1] && S[i - 1] == T[0]) {
        count++;
        S.erase(S.end() - (i));
        S.erase(S.end() - (i + 1));
        i = l;
      }
    }
    cout << l - (2 * count);
  }
  return 0;
}
