#include <bits/stdc++.h>
using namespace std;
int main() {
  string str;
  cin >> str;
  int scnt = 0, tcnt = 0, total = str.size();
  bool flag = true;
  for (int i = 0; i < str.size(); i++) {
    if (flag && str[i] == 'S') {
      scnt++;
    }
    if (flag && str[i] == 'T' || str[i] == 'T') {
      tcnt++;
      flag = false;
    }
    if (flag == false && str[i] == 'S') {
      flag = true;
      i--;
      total -= min(scnt, tcnt) * 2;
      scnt = 0;
      tcnt = 0;
    }
  }
  if (scnt > 0 && tcnt > 0) {
    total -= min(scnt, tcnt) * 2;
  }
  cout << total << endl;
}
