#include <bits/stdc++.h>
using namespace std;
int count(const string& x, const vector<int>& index) {
  int size = 0;
  for (int pos = index[0]; pos < x.size(); pos = index[pos + 1]) {
    ++size;
  }
  return size;
}
long solve(const string& x) {
  vector<int> index(x.size() + 1);
  iota(index.begin(), index.end(), 0);
  while (true) {
    int sbegin = -1;
    int send = -1;
    int slen = 0;
    int tlen = 0;
    bool prev_s = false;
    int prev_pos = -1;
    for (int pos = index[0]; pos < x.size(); pos = index[pos + 1]) {
      auto c = x[pos];
      if (c == 'S') {
        if (slen > tlen && tlen > 0) {
          break;
        }
        tlen = 0;
        if (prev_s) {
          ++slen;
        } else {
          sbegin = prev_pos;
          slen = 1;
          prev_s = true;
        }
      } else {
        if (prev_s) {
          tlen = 1;
        } else {
          ++tlen;
        }
        prev_s = false;
        if (tlen == slen) {
          send = pos;
          break;
        }
      }
      prev_pos = pos;
    }
    if (tlen == 0) {
      return count(x, index);
    }
    int diff = slen - tlen;
    for (int i = 0; i < diff; ++i) {
      sbegin = index[sbegin + 1];
    }
    index[sbegin + 1] = index[send + 1];
  }
}
int main() {
  string x;
  cin >> x;
  cout << solve(x) << endl;
  return 0;
}
