#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  long long ans = 0, l = 0, r = s.size() - 1;
  for (long long i = 0; i < s.size(); i++) {
    if (s[i] == 'T') {
      ans++;
      l++;
    } else {
      break;
    }
  }
  for (long long i = r; i >= 0; i--) {
    if (s[i] == 'S') {
      ans++;
      r--;
    } else {
      break;
    }
  }
  long long ans2 = 0;
  for (long long j = l; j <= r; j++) {
    if (s[j] == 'S') {
      ans2++;
    } else {
      ans2--;
    }
  }
  cout << ans + abs(ans2);
  return 0;
}
