#include <bits/stdc++.h>
using namespace std;
void solve() {
  string s;
  cin >> s;
  int cnt = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] != 'S') continue;
    for (int j = i + 1; j < s.size(); j++) {
      if (s[j] == 'T') {
        cnt++;
        s[j] = 'K';
        break;
      }
    }
  }
  cout << (s.size() - (2 * cnt)) << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
