#include <bits/stdc++.h>
using namespace std;
int dx[4]{-1, +1, 0, 0};
int dy[4]{0, 0, -1, +1};
int main() {
  string s;
  cin >> s;
  int numt = 0;
  int nums = 0;
  bool ok = false;
  for (int i = 0; i < (int)s.size(); i++) {
    if (s[i] == 'S') {
      ok = true;
    } else if (s[i] == 'T' && ok) {
      numt++;
    }
  }
  ok = false;
  for (int i = s.size() - 1; i >= 0; i--) {
    if (s[i] == 'T') {
      ok = true;
    } else if (s[i] == 'S' && ok) {
      nums++;
    }
  }
  cout << s.size() - 2 * min(nums, numt) << endl;
}
