#include <bits/stdc++.h>
const int maxn = 1e5 + 10;
using namespace std;
long long gcd(long long p, long long q) { return q == 0 ? p : gcd(q, p % q); }
long long qpow(long long p, long long q) {
  long long f = 1;
  while (q) {
    if (q & 1) f = f * p;
    p = p * p;
    q >>= 1;
  }
  return f;
}
int n, m, k, t;
inline long long read() {
  long long x = 0;
  int f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
char a[maxn];
stack<char> p;
int main() {
  int i, j;
  scanf("%s", &a);
  for (i = 0; a[i]; i++) {
    if (!p.empty() && p.top() == 'S' && a[i] == 'T')
      p.pop();
    else
      p.push(a[i]);
  }
  printf("%d\n", p.size());
  return 0;
}
