#include <bits/stdc++.h>
using namespace std;
constexpr int kMod = 1000000007;
int main() {
  string S;
  cin >> S;
  int t1 = -1, t2 = 0;
  int s1 = -1, s2 = 0;
  for (int i = 0; i < S.size(); ++i) {
    if (S[i] == 'S') {
      if (s1 < 0) s1 = i;
      s2 = i;
    } else {
      if (t1 < 0) t1 = i;
      t2 = i;
    }
  }
  int cnt = 0;
  for (int i = S.size() - 1; i >= 0; --i) {
    if (S[i] == 'T' && i < s1) {
      ++cnt;
    }
  }
  for (int i = 0; i < S.size(); ++i) {
    if (S[i] == 'S' && i > t2) {
      ++cnt;
    }
  }
  if (cnt == 0)
    cout << 0 << endl;
  else
    cout << cnt + 1 << endl;
}
