#include <bits/stdc++.h>
using namespace std;
int main() {
  string x;
  cin >> x;
  long long i = 0;
  long long count = 0;
  while (i < x.size()) {
    if (x[i] == 'S') {
      long long length_s = 0;
      while (i < x.size() and x[i] == 'S') {
        i++;
        length_s++;
      }
      long long length_t = 0;
      while (i < x.size() and x[i] == 'T') {
        i++;
        length_t++;
      }
      count += min(length_s, length_t);
    } else {
      i++;
    }
  }
  cout << x.size() - 2 * count << endl;
  return 0;
}
