#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
int n, cnt, ss;
string x, cur;
bool ok;
stack<char> st;
int main() {
  cin >> x;
  int n = (int)x.size();
  for (size_t i = 0; (int)i < n; ++i) {
    if (x[i] == 'S')
      ss++;
    else {
      if (ss)
        ss--;
      else
        cnt++;
    }
  }
  cout << cnt + ss;
  return 0;
}
