#include <bits/stdc++.h>
using namespace std;
int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
int main() {
  string x;
  cin >> x;
  while (1) {
    if ((int)x.find("ST") == -1) break;
    int p = (int)x.find("ST");
    x.erase(x.begin() + p, x.begin() + p + 2);
  }
  cout << x.size() << endl;
}
