#include <bits/stdc++.h>
using namespace std;
typedef std::priority_queue<int> IntPrioQueue;
typedef std::priority_queue<int, std::vector<int>, std::greater<int> >
    IntReversePrioQueue;
template <class T>
ostream &operator<<(ostream &o, const vector<T> &v) {
  o << "{";
  for (int i = 0; i < (int)v.size(); i++) o << (i > 0 ? ", " : "") << v[i];
  o << "}";
  return o;
}
const int MAX = 200000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1 << 31 - 1;
const int MOD = 1000000007;
void solve(void) {
  string S;
  cin >> S;
  int L = S.length();
  int cnt = 0, ans = 0;
  for (char c : S) {
    if (c == 'S') {
      cnt++;
    } else {
      if (cnt < 0) cnt--;
      ans = max(ans, cnt);
    }
  }
  cout << L - ans * 2 << endl;
}
int main(void) {
  solve();
  return 0;
}
