#include <bits/stdc++.h>
using namespace std;
constexpr long long mod = 1e9 + 7;
int main() {
  string s;
  cin >> s;
  s += '#';
  int n = int(s.size());
  vector<pair<char, int>> a;
  int l = 0;
  for (int i = 0; i < n; i++) {
    if (s[l] != s[i]) {
      a.emplace_back(make_pair(s[l], i - l));
      l = i;
    }
  }
  int idx = -1;
  int m = int(a.size());
  for (int i = 0; i < m; i++) {
    if (a[i].first == 'S') {
      idx = i;
      break;
    }
  }
  int res = n - 1;
  for (int i = idx; i < m; i += 2) {
    int cnt = min(a[i].second, a[i + 1].second);
    res -= cnt * 2;
  }
  cout << res << endl;
  return 0;
}
