#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-14;
const double PI = acos(-1.0);
int main() {
  string s;
  cin >> s;
  for (int i = (0); i < (100000); i++) {
    int st = s.find("ST");
    if (st > -1) s.erase(st, 2);
  }
  printf("%d\n", int(s.size()));
}
