#include <bits/stdc++.h>
using namespace std;
string IntToString(long long number) {
  stringstream ss;
  ss << number;
  return ss.str();
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string x;
  int ans, pos;
  cin >> x;
  while (1) {
    pos = x.find("ST");
    if (pos != string ::npos) {
      x.erase(pos, 2);
    } else {
      break;
    }
  }
  cout << x.length() << endl;
}
