#include <bits/stdc++.h>
constexpr int MOD = 1000000000 + 7;
constexpr int INF = 2000000000;
using namespace std;
using LL = long long;
int main() {
  string s;
  cin >> s;
  s += "  ";
  bool update = true;
  while (update) {
    int num = s.size();
    for (int i = 0; i < s.size() - 1; i++) {
      if (s.substr(i, 2) == "ST") {
        s.erase(s.begin() + i, s.begin() + i + 2);
        break;
      }
    }
    if (num == s.size()) update = false;
  }
  cout << s.size() - 2 << endl;
}
