#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int INF = 1e9;
int main() {
  string s;
  cin >> s;
  int cnt = 0;
  int scnt = 0;
  int tcnt = 0;
  int i = 0;
  while (cnt < s.size() / 2) {
    if (s[i] == 'T') {
      cnt++;
      if (scnt) tcnt++;
    }
    if (s[i] == 'S') scnt++;
    i++;
  }
  cout << s.size() - 2 * min(tcnt, scnt) << endl;
}
