#include <bits/stdc++.h>
using namespace std;

string X;
int L;

int main() {
  cin >> X; L = X.size();
  int cur = 0, bottom = 0;
  for(int i = 0; i < L; ++i) {
    cur += X[i] == 'S' ? 1 : -1;
    bottom = min(bottom, cur);
  }
  cout << (-bottom) * 2 << endl;
  return 0;
}
