#include <bits/stdc++.h>
using namespace std;
vector<char> strem(vector<char> &p) {
  int cc = 0, j = p.size();
  for (int i = 0; i < j; ++i) {
    if ((p[i] == 'S') && (p[i + 1] == 'T')) {
      cc = 1;
      p.erase(p.begin() + i, p.begin() + i + 2);
      return strem(p);
    }
  }
  return p;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<char> inp, temp;
  char tmp;
  while (cin >> tmp) {
    inp.push_back(tmp);
  }
  temp = strem(inp);
  cout << temp.size();
}
