#include <bits/stdc++.h>
using namespace std;
const int inf = 999999999;
const int mod = 1000000007;
int main() {
  string s;
  cin >> s;
  int len = s.size();
  int ans = len;
  while (1) {
    bool flag = true;
    for (int i = (0); i < ((len - 1)); i++) {
      string k = s.substr(i, 2);
      if (k == "ST") {
        s.erase(i, 2);
        ans -= 2;
        flag = false;
        break;
      }
    }
    len = s.size();
    if (flag || len == 0) break;
  }
  cout << ans << endl;
  return 0;
}
