#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
const int MOD = (int)1e9 + 7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string x;
  cin >> x;
  int s = 0, t = 0, minus = 0;
  for (int i = 0; i < x.size(); i++) {
    if (x[i] == 'S') s++;
    if (x[i] == 'T') {
      t++;
      if (s != 0) minus -= 2 * s, s = 0, t = 0;
    }
  }
  cout << (int)x.size() + minus << endl;
  return 0;
}
