#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string x;
  cin >> x;
  int len = x.size();
  int i = 0;
  while (i < len - 1) {
    if (x[i] == 'S' && x[i + 1] == 'T') {
      x.erase(i, 2);
      len -= 2;
      i = 0;
      continue;
    }
    ++i;
  }
  cout << len << '\n';
  return 0;
}
