#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const long long MOD = 1000000007;
const long long INF = 1e10;
const long long MAX_N = 1010;
long long fac[MAX_N], finv[MAX_N], inv[MAX_N];
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX_N; i++) {
    fac[i] = fac[i - 1] * i;
  }
}
long long COM(long long n, long long k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  if (n > k * 2) {
  }
  return fac[n] / (fac[k] * fac[n - k]);
}
long long dx[4] = {0, 0, -1, 1};
long long dy[4] = {-1, 1, 0, 0};
long long h, w;
char a[1010][1010];
bool dp[101010];
int main() {
  string s;
  cin >> s;
  long long n = s.length();
  long long ans = s.length();
  bool flag = false;
  long long t = 0;
  for (long long i = n - 1; i >= 0; --i) {
    if (s[i] == 'T' && flag == false) {
      flag = true;
      t = 1;
    } else if (s[i] == 'T' && flag == true) {
      t++;
    } else if (s[i] == 'S' && flag == true) {
      flag = false;
      if (t > 0) {
        t--;
        ans -= 2;
      }
    } else {
      if (t > 0) {
        t--;
        ans -= 2;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
