#include <bits/stdc++.h>
using namespace std;
int find(string &str) {
  int len = str.length(), l = 2;
  for (int i = 0; i < len - 1; i++) {
    if (str[i] == 'S' && str[i + 1] == 'T') return i;
  }
  return -1;
}
void delet(string &str) {
  int k, l = 2;
  while (1) {
    if ((k = find(str)) < 0) break;
    str.erase(k, l);
  }
  cout << str.length() << endl;
}
int main() {
  string a;
  cin >> a;
  delet(a);
  return 0;
}
