#include <bits/stdc++.h>
using namespace std;
int main() {
  string X;
  cin >> X;
  int L = X.size();
  vector<int> num(L + 1);
  num.at(0) = 0;
  int ans = 0;
  for (int i = 1; i < L; i++) {
    if (X.at(i) == 'S')
      num.at(i) = num.at(i - 1) + 1;
    else if (num.at(i - 1) > 0) {
      num.at(i) = num.at(i - 1) - 1;
      ans++;
    } else
      num.at(i) = num.at(i - 1);
  }
  cout << L - ans * 2 << endl;
}
