#include <bits/stdc++.h>
using namespace std;
const int maxn = 2 * 1e5 + 10;
int judge(string s) {
  stack<char> res;
  int size = s.size();
  for (int i = 0; i < size; i++) {
    if (res.empty()) {
      res.push(s[i]);
      continue;
    }
    if (res.top() == 'S' && s[i] == 'T') {
      res.pop();
      size = size - 2;
    } else {
      res.push(s[i]);
    }
  }
  return size;
}
int main() {
  string s;
  cin >> s;
  cout << judge(s) << endl;
  return 0;
}
