#include <bits/stdc++.h>
using namespace std;
long long v[100000];
int main() {
  string s;
  cin >> s;
  int i = 0;
  int l = 0;
  int r = 0;
  int cnt = 0;
  while (i < s.size() - 1 && i < pow(10, 4)) {
    l = i;
    r = i + 1;
    while (0 <= l && r < s.size() && s[l] == 'S' && s[r] == 'T') {
      cnt++;
      l--;
      r++;
      i = r - 1;
    }
    i++;
  }
  cout << s.size() - cnt * 2 << endl;
  return 0;
}
