#include <bits/stdc++.h>
using namespace std;
template <typename T>
void remove(vector<T>& vector, unsigned int index) {
  vector.erase(vector.begin() + index);
}
int main() {
  char x[200005];
  cin >> x;
  int lx = strlen(x);
  vector<char> a;
  for (int i = 0; i < lx; i++) {
    a.push_back(x[i]);
  }
  int la = lx;
  for (int i = 1; i < la; i++) {
    if (a[i - 1] == 'S' && a[i] == 'T') {
      remove(a, i - 1);
      remove(a, i - 1);
      i = 0;
      la -= 2;
    }
  }
  cout << a.size() << endl;
}
