#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;
void Main() {
  string x;
  cin >> x;
  int n = x.size();
  vi S(n, 0), T(n, 0);
  for (int(i) = 0; (i) < (n); (i)++) {
    if (i == 0) {
      if (x[i] == 'S')
        S[i] = 1;
      else
        T[i] = 1;
    } else {
      if (x[i] == 'S') {
        S[i] = S[i - 1] + 1;
        T[i] = T[i - 1];
      } else {
        S[i] = S[i - 1];
        T[i] = T[i - 1] + 1;
      }
    }
  }
  auto itr = lower_bound((T.begin()), (T.end()), n / 2);
  int last = itr - T.begin();
  cout << n - 2 * S[last] << endl;
  return;
}
int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
  return 0;
}
