#include <bits/stdc++.h>
using namespace std;
class question {
 public:
  string X;
  void ans() {
    cin >> X;
    int n = X.size();
    int res = n;
    int l = 0, r = 1;
    while (r < n) {
      while (r < n && !(X[r - 1] == 'S' && X[r] == 'T')) {
        l = r;
        r++;
      }
      while (l >= 0 && r < n && X[l] == 'S' && X[r] == 'T') {
        res -= 2;
        l--;
        r++;
      }
    }
    cout << res << "\n";
  }
};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  question q;
  q.ans();
  return 0;
}
