#include <bits/stdc++.h>
using namespace std;
int main() {
  string a;
  cin >> a;
  int b = a.size();
  vector<int> wc(b / 2);
  int c = -1;
  int d = -1;
  for (int i = 0; i < b; i++) {
    if (a.at(i) == 'T' && d != -1) c = c + 1;
    if (a.at(i) == 'S' && d == -1) {
      d = 0;
      c = 0;
    } else if (a.at(i) == 'S' && c != -1) {
      wc.at(d) = c;
      d = d + 1;
      c = 0;
    }
  }
  wc.at(b / 2 - 1) = c;
  int e = 0;
  int f = 0;
  for (int i = 0; i < b; i++) {
    for (int j = 0; j < b / 2; j++) {
      if (j == 0 && wc.at(0) > 0) {
        wc.at(0) = 0;
        e = e + 1;
        break;
      } else if (wc.at(j) > 0) {
        wc.at(j - 1) = wc.at(j) - 1;
        wc.at(j) = 0;
        e = e + 1;
        break;
      } else if (j == b / 2 - 1)
        f = 1;
    }
    if (f == 1) break;
  }
  cout << b - 2 * e;
}
