#include <bits/stdc++.h>
using namespace std;
const long long INF = 1ll << 60;
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
string X;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> X;
  int tmp = 0;
  vector<int> S;
  for (int i = X.length() - 1; i >= 0; i--) {
    if (X[i] == 'T')
      tmp++;
    else
      S.push_back(tmp);
  }
  int rsl = 0;
  for (int i = (int)0; i < (int)S.size(); i++) {
    if (S[i]) rsl++;
  }
  cout << X.size() - 2 * rsl << endl;
}
