#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
int main() {
  string x;
  cin >> x;
  int s = 0, t = 0, border = 0;
  for (int i = (int)x.length() - 1; i >= 0; i--) {
    if (x[i] == 'T') {
      border = i + 1;
      break;
    } else {
      continue;
    }
  }
  for (int i = 0; i < border; i++) {
    if (x[i] == 'S')
      s++;
    else
      t++;
  }
  cout << x.length() - min(s, t) * 2 << endl;
  return 0;
}
