#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  string ans;
  int flag, j;
  while (1) {
    if (s.length() == 0) break;
    flag = j = 0;
    for (int i = 0; i < s.length() - 1; i++) {
      if (s[i] == 'S' && s[i + 1] == 'T') {
        flag = 1;
        i++;
      } else {
        ans += s[i];
        j++;
      }
    }
    if (s[s.length() - 2] == 'S' && s[s.length() - 1] == 'T') {
    } else
      ans += s[s.length() - 1];
    if (flag == 0) break;
    s = "";
    s = ans;
    ans = "";
  }
  cout << ans.length() << endl;
  return 0;
}
