#include <bits/stdc++.h>
using namespace std;
static const double EPS = 1e-9;
template <class T>
bool INRANGE(T x, T a, T b) {
  return a <= x && x <= b;
}
template <class T>
void amin(T &a, T v) {
  if (a > v) a = v;
}
template <class T>
void amax(T &a, T v) {
  if (a < v) a = v;
}
int ROUND(double x) { return (int)(x + 0.5); }
bool ISINT(double x) { return fabs(ROUND(x) - x) <= EPS; }
bool ISEQUAL(double x, double y) {
  return fabs(x - y) <= EPS * max(1.0, max(fabs(x), fabs(y)));
}
double SQSUM(double x, double y) { return x * x + y * y; }
int main() {
  queue<char> ls;
  string s;
  cin >> s;
  for (int i = 0; i < ((int)(s).size()); ++i) {
    ls.push(s[i]);
    while (((int)(ls).size()) >= 2) {
      char lst = ls.back();
      ls.pop();
      char lst2 = ls.back();
      ls.pop();
      if (lst == 'T' && lst2 == 'S') {
      } else {
        ls.push(lst2);
        ls.push(lst);
        break;
      }
    }
  }
  printf("%d\n", ((int)(ls).size()));
  return 0;
}
