#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int s = 0, t = 0;
  int t_end;
  string x;
  cin >> x;
  int baselength = (int)x.size();
  int length = baselength;
  for (int pos = 0; pos < baselength;) {
    while (x[pos] == 'S' && pos < baselength) {
      s++;
      pos++;
    }
    while (x[pos] == 'T' && pos < baselength) {
      t++;
      pos++;
    }
    length -= min(s, t) * 2;
    s = 0;
    t = 0;
  }
  cout << length << endl;
}
