#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int i, j, cnt = 0;
  string x;
  cin >> x;
  for (i = 0; i < x.size(); i++) {
    if (x[x.size() - 1 - i] == 'S')
      cnt++;
    else
      break;
  }
  int s = 0, t = 0;
  for (; i < x.size(); i++) {
    if (x[x.size() - 1 - i] == 'S')
      s++;
    else
      t++;
  }
  cout << x.size() - 2 * min(s, t) << endl;
}
