#include <bits/stdc++.h>
using namespace std;
template <typename T>
void cins(vector<T>& arr) {
  for (T& e : arr) cin >> e;
}
int main(void) {
  string str;
  cin >> str;
  int ans = 0;
  int idx = 0;
  for (; idx < str.length(); idx++) {
    if (str[idx] == 'S') break;
    ans++;
  };
  str.push_back(0);
  int prev = 'S';
  int cnt = 0;
  vector<int> arr;
  for (; idx < str.length(); idx++) {
    int cur = str[idx];
    if (cur == prev) {
      cnt++;
      continue;
    }
    arr.push_back(cnt);
    cnt = 1;
    prev = cur;
  };
  int scnt = 0;
  for (int i = 0; i < arr.size(); i += 2) {
    int s = arr[i] + scnt;
    int t = arr[i + 1];
    ;
    if (s < t) {
      ans += (t - s);
    } else {
      scnt = s - t;
    }
  }
  cout << ans + scnt << endl;
  return 0;
}
