#include <bits/stdc++.h>
using namespace std;
int main() {
  string A;
  cin >> A;
  for (int x = 0; x < A.length(); x++) {
    if (A[x] == 'S' && A[x + 1] == 'T') {
      A.erase(x, 2);
      x = 0;
    }
  }
  cout << A.length() << "\n";
}
