#include <bits/stdc++.h>
using namespace std;
enum STATE { IDLE, CNTS, CNTT };
int main() {
  string s;
  cin >> s;
  int total = s.size();
  int scnt = 0;
  STATE st = IDLE;
  for (int i = 0; i < int(s.size()); ++i) {
    switch (st) {
      case IDLE:
        scnt = 0;
        if (s[i] == 'S') {
          scnt++;
          st = CNTS;
        }
        break;
      case CNTS:
        if (s[i] == 'T') {
          st = CNTT;
          total -= 2;
          scnt--;
        } else {
          scnt++;
        }
        break;
      case CNTT:
        if (s[i] == 'S') {
          scnt = 1;
          st = CNTS;
        } else {
          if (scnt > 0) {
            scnt--;
            total -= 2;
          }
        }
        break;
      default:
        break;
    }
  }
  cout << total << endl;
  return 0;
}
