#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int N = 1e6 + 500;
const int lgN = 20;
const long long int INF = 1e16;
int main(int argc, char const *argv[]) {
  cin.sync_with_stdio(0);
  cin.tie(0);
  string s;
  cin >> s;
  int ans = 0;
  while (s.size() > 0) {
    if (*(s.begin()) == 'T') {
      ans++;
      s.erase(s.begin());
    } else
      break;
  }
  while (s.size() > 0) {
    if (*(s.end() - 1) == 'S') {
      ans++;
      s.erase(s.end() - 1);
    } else
      break;
  }
  int a = 0, b = 0;
  for (auto c : s)
    if (c == 'T')
      a++;
    else
      b++;
  ans += max(a, b) - min(a, b);
  cout << ans << '\n';
  return 0;
}
