#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1e9;
const int mod = inf + 7;
const double eps = 1e-9;
const double pi = acos(-1.0);
string x;
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  cin >> x;
  while (true) {
    int len = x.length();
    if (len == 0) break;
    for (int i = 0; i < x.length() - 1; ++i) {
      if (x[i] == 'S' && x[i + 1] == 'T') {
        string second, q;
        for (int j = 0; j < i; ++j) {
          second += x[j];
        }
        for (int j = i + 2; j < x.length(); ++j) {
          second += x[j];
        }
        x = second;
        break;
      }
    }
    if (x.length() == len) break;
  }
  cout << x.length() << endl;
}
