#include <bits/stdc++.h>
using namespace std;
char c[200099];
int main() {
  string s;
  int i = 0;
  while (scanf("%c", &c[i]) != EOF) {
    i++;
  }
  s = c;
  int k = s.find("ST");
  while (k != -1) {
    s.erase(k, 2);
    i = i - 2;
    k = s.find("ST");
  }
  cout << i - 1 << endl;
  return 0;
}
