#include <bits/stdc++.h>
using namespace std;
const long long INF = 1000000000000000001;
struct edge {
  int to, cost;
};
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
struct Road {
  double cost;
  int a, b;
};
int main() {
  string x;
  cin >> x;
  long long total = x.size(), s = 0, t = 0;
  for (int i = 0; i < x.size(); ++i) {
    if (x[i] == 'S') s++;
    if (x[i] == 'T') {
      t++;
      if (x[i + 1] != 'T') {
        total -= 2 * min(s, t);
        s = 0;
        t = 0;
      }
    }
  }
  cout << total << endl;
  return 0;
}
