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