#include <bits/stdc++.h>
using namespace std;
int main() {
  string a;
  int l;
  cin >> a;
  l = a.size();
  int i, c = 0, res = 0, s = 0, t = 0;
  for (i = l - 1; i >= 0; i--) {
    if (a[i] == 'T') {
      c = i;
      break;
    }
  }
  for (i = 0; i <= c; i++) {
    if (a[i] == 'T') {
      t++;
    } else if (a[i] == 'S')
      s++;
  }
  res = abs(s - t) * 2;
  cout << res << endl;
  return 0;
}
