#include <bits/stdc++.h>
using namespace std;
string S;
int main() {
  cin >> S;
  int high = 0;
  int cnt = 0;
  int a = 0;
  for (int i = 0; i < S.length(); i++) {
    if (S[i] == 'S') {
      cnt++;
      high = max(high, cnt);
    } else {
      if (cnt > 0) cnt--;
    }
    if (cnt == 0) {
      a += high;
      high = 0;
    }
  }
  cout << S.length() - 2 * a << endl;
  return 0;
}
