#include <bits/stdc++.h>
template <class T, class S>
void cmin(T &a, const S &b) {
  if (a > b) a = b;
}
template <class T, class S>
void cmax(T &a, const S &b) {
  if (a < b) a = b;
}
using namespace std;
int main() {
  string s;
  cin >> s;
  int cnt = 0;
  bool flag = true;
  while (true) {
    if (s.find("ST") == string::npos || s.size() == 0) break;
    int x = (int)s.find("ST");
    s.erase(s.begin() + x);
    s.erase(s.begin() + x);
    cnt++;
  }
  cout << s.size() << endl;
}
