#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  for (ll i = (0), __last_i = (v.size()); i < __last_i; i++) {
    if (i) os << " ";
    os << v[i];
  }
  return os;
}
template <typename T>
ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
  for (ll i = (0), __last_i = (v.size()); i < __last_i; i++) {
    if (i) os << endl;
    os << v[i];
  }
  return os;
}
const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;
int main() {
  string s;
  ll ans = 0;
  cin >> s;
  ll t = s.size() / 2;
  for (ll i = (0), __last_i = (s.size()); i < __last_i; i++) {
    if (t > 0 && s[i] == 'S') {
      ans += 2;
    } else if (s[i] == 'T') {
      t--;
    }
  }
  cout << s.size() - ans << endl;
}
