#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}
const double EPS = 1e-10;
const double PI = acos(-1.0);
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S;
  cin >> S;
  int cur = 0;
  int ret = 0;
  for (auto c : S) {
    if (c == 'S')
      cur++;
    else
      cur--;
    if (cur < 0) ret++;
  }
  cout << ret << endl;
  return 0;
}
