#include <bits/stdc++.h>
using namespace std;
const int INF = INT_MAX;
const long long INFL = LONG_LONG_MAX;
const double PI = atan(1) * 4;
const int MOD = pow(10, 9) + 7;
int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x;
  return is;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  }
  return os;
}
int main() {
  string X;
  cin >> X;
  vector<int> Spos(X.size() / 2);
  vector<int> Tpos(X.size() / 2);
  int a, b;
  a = b = 0;
  for (auto j = 0; j < X.size(); j++) {
    if (X[j] == 'T') {
      Tpos[a] = j;
      a++;
    } else {
      Spos[b] = j;
      b++;
    }
  }
  int ans = (int)X.size();
  auto searchI = Tpos.begin();
  for (auto i = 0; i < Spos.size(); i++) {
    searchI = lower_bound(searchI, Tpos.end(), Spos[i]);
    if (searchI == Tpos.end()) break;
    ans -= 2;
  }
  cout << ans << endl;
  return 0;
}
