#include <bits/stdc++.h>
using namespace std;
vector<pair<char, int>> compress(string s) {
  vector<pair<char, int>> res;
  for (int i = 0; i < s.size(); i++) {
    int p = 0;
    while (i + p < s.size() && s[i] == s[i + p]) {
      p++;
    }
    res.push_back(make_pair(s[i], p));
    i += p - 1;
  }
  return res;
}
int main() {
  string s;
  cin >> s;
  auto res = compress(s);
  int ans = 0;
  for (int i = 0; i < res.size(); i++) {
    if (res[i].first == 'S' && i + 1 < res.size()) {
      ans += 2 * min(res[i].second, res[i + 1].second);
    }
  }
  cout << s.size() - ans << endl;
}
