#include <bits/stdc++.h>
using ll = long long;
using namespace std;
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
int main() {
  string s;
  cin >> s;
  bool f = true;
  while (f) {
    bool f = true;
    for (int i = 0; i < ((ll)(s).size()) - 1; i++) {
      if (s[i] == 'S' && s[i + 1] == 'T') {
        s.erase(i, 2);
        f = false;
        i--;
      }
    }
    if (f) break;
  }
  cout << ((ll)(s).size()) << "\n";
  return 0;
}
