#include <bits/stdc++.h>
using namespace std;
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;
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long modinv(long long a, long long m) {
  long long b = m, u = 1, v = 0;
  while (b) {
    long long t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}
vector<pair<long long, long long>> prim;
void pf(long long n) {
  long long s = sqrt(n);
  long long r = 0;
  for (long long i = 2; i <= s; i++) {
    if ((n % i) == 0) {
      r = 0;
      do {
        r++;
        n = n / i;
      } while ((n % i) == 0);
      prim.push_back({i, r});
    }
  }
  if (n > s) {
    prim.push_back({n, 1});
  }
}
void solve() {
  string s;
  cin >> s;
  long long ans = 0;
  long long tc = 0, sc = 0;
  bool f = false;
  for (long long i = 0; i < (s.size()); i++) {
    if (s[i] == 'S') f = true;
    if (f && s[i] == 'T') tc++;
  }
  reverse(s.begin(), s.end());
  f = false;
  for (long long i = 0; i < (s.size()); i++) {
    if (s[i] == 'T') f = true;
    if (f && s[i] == 'S') sc++;
  }
  ans = s.size() - min(tc, sc) * 2;
  cout << ans << endl;
}
int main(void) { solve(); }
