#include <bits/stdc++.h>
using namespace std;
int main() {
  string X;
  cin >> X;
  int64_t cnt = 0;
  for (int i = 0; i < X.size() - 1; i++) {
    if (X.at(i) == 'S' && X.at(i + 1) == 'T') {
      int64_t l = i, r = i + 1;
      while (l >= 0 && r < X.size()) {
        if (X.at(l) == 'S' && X.at(r) == 'T') {
          cnt++;
          l--;
          r++;
        } else {
          break;
        }
      }
    }
  }
  cout << X.size() - 2 * cnt << endl;
}
