#include <bits/stdc++.h>
using namespace std;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int main() {
  string s;
  cin >> s;
  int ssz = s.size();
  int ctr = (s[0] == 'S' ? 1 : -1);
  int res = 0;
  for (int i = int(0); i < int(ssz - 1); ++i) {
    if (s[i + 1] == 'S' && s[i] == 'T') {
      res += ctr;
      ctr = 0;
    } else {
      if (s[i + 1] == 'S')
        ctr++;
      else
        ctr--;
    }
  }
  cout << -res + ctr << endl;
}
