#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
int main() {
  string X;
  cin >> X;
  vector<int> S;
  vector<int> T;
  for (int i = 0; i < X.size(); i++) {
    if (X[i] == 'S') {
      S.push_back(i);
    } else {
      T.push_back(i);
    }
  }
  int scount = 0;
  for (auto s : S) {
    auto iter = lower_bound((T).begin(), (T).end(), s);
    if (iter != T.end()) scount++;
  }
  int tcount = 0;
  reverse((S).begin(), (S).end());
  for (auto t : T) {
    auto iter = lower_bound((S).begin(), (S).end(), t, greater<int>());
    if (iter != S.end()) tcount++;
  }
  cout << X.size() - 2 * min(scount, tcount) << endl;
  return 0;
}
