#include <bits/stdc++.h>
const int inf = (1 << 30);
const int mod = 1000000007;
using ll = long long;
using namespace std;
int main() {
  string x;
  cin >> x;
  int sz = x.size();
  int tl = sz;
  for (int i = 0; i < sz; ++i) {
    if (x[i] == 'S') {
      tl = i;
      break;
    }
  }
  reverse(x.begin(), x.end());
  int sr = sz;
  for (int i = 0; i < sz; ++i) {
    if (x[i] == 'T') {
      sr = i;
      break;
    }
  }
  reverse(x.begin(), x.end());
  sr = sz - sr;
  int s = 0, t = 0;
  for (int i = tl; i < sr; ++i) {
    if (x[i] == 'S')
      ++s;
    else
      ++t;
  }
  cout << sz - 2 * min(s, t) << endl;
}
