#include <bits/stdc++.h>
using namespace std;
int main() {
  string x;
  cin >> x;
  bool flag = 1;
  bool flag_ = 1;
  while (true) {
    flag = 1;
    flag_ = 1;
    for (int m = 0; m < x.length(); m++) {
      if (x[m] == 'S' && x[m + 1] == 'T') {
        x.erase(m, 2);
        flag = 0;
        flag_ = 0;
      }
      if (flag_ == 0) {
        flag_ = 1;
        break;
      }
    }
    if (flag == 1) {
      break;
    }
  }
  cout << x.size();
}
