#include <bits/stdc++.h>
using namespace std;
string str;
int l;
int next(int a) {
  int i = a + 1;
  while (str[i] == '0') {
    i++;
  }
  return i;
}
bool rem() {
  int i = 0;
  int n = next(i);
  bool flag = false;
  while (n < l) {
    n = next(i);
    if (str[i] == 'S' && str[n] == 'T') {
      str[i] = '0';
      str[n] = '0';
      flag = true;
    }
    i = n;
  }
  return flag;
}
int main() {
  cin >> str;
  int cnt = 0;
  l = str.length();
  while (rem()) {
  }
  for (int i = 0; i < l; i++) {
    if (str[i] != '0') {
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}
