#include <bits/stdc++.h>
using namespace std;
__inline__ __attribute__((always_inline)) void read(int &x) {
  int res = 0, f = 1;
  char c = getchar();
  if (c == '-') f = -1;
  while (c > '9' || c < '0') c = getchar();
  while (c >= '0' && c <= '9') {
    res = res * 10 + c - '0';
    c = getchar();
  }
  x = res * f;
}
inline void print(int x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) print(x / 10);
  putchar(x % 10 + '0');
}
string s;
int main() {
  cin >> s;
  while (!s.empty() && s.find("ST") != string::npos) s.erase(s.find("ST"), 2);
  cout << s.size() << "\n";
  exit(0);
}
