#include <bits/stdc++.h>
using namespace std;
int main(int argc, char** argv) {
  string str;
  cin >> str;
  bool flag = true;
  int lenstr = str.size();
  int cnt = 0;
  while (flag == true) {
    flag = false;
    int len = str.size();
    for (int i = 0; i < len - 1; i++) {
      if (str[i] == 'S' && str[i + 1] == 'T') {
        str[i] = '.';
        str[i + 1] = '.';
        cnt += 2;
        flag = true;
      }
    }
    string new_S = "";
    for (int i2 = 0; i2 < len; i2++) {
      if (str[i2] != '.') {
        new_S += str[i2];
      }
    }
    str = new_S;
  }
  cout << lenstr - cnt;
  return 0;
}
