#include <bits/stdc++.h>
using namespace std;
signed main() {
  string st;
  cin >> st;
  int n = int(st.size());
  int left, right;
  for (left = 0; left < n; ++left) {
    if (st[left] == 'S') break;
  }
  for (right = n - 1; right >= 0; --right) {
    if (st[right] == 'T') break;
  }
  if (right < left)
    cout << n << '\n';
  else {
    int s = 0, t = 0;
    for (int i = left; i <= right; ++i) {
      if (st[i] == 'S')
        ++s;
      else
        ++t;
    }
    cout << n - 2 * min(s, t) << '\n';
  }
}
