#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9 + 7;
const long long LINF = 1e18;
using namespace std;
void CINT() {}
template <class Head, class... Tail>
void CINT(Head&& head, Tail&&... tail) {
  cin >> head;
  CINT(move(tail)...);
}
int main() {
  string s;
  CINT(s);
  vector<int> v;
  int n = s.size();
  for (int i = 0; i < (s.size()); ++i) v.push_back(s[i] == 'T');
  set<int> tflag;
  for (int i = 0; i < (n); ++i) {
    if (v[i]) continue;
    for (int j = (i + 1); j < (n); ++j) {
      if (v[j] && !tflag.count(j)) {
        tflag.insert(j);
        break;
      }
    }
  }
  cout << (n - tflag.size() * 2) << endl;
  return 0;
}
