#include <bits/stdc++.h>
using namespace std;
int main() {
  string X;
  cin >> X;
  vector<int> v;
  int cnt = 0;
  char c = 'S';
  for (int i = 0; i < X.size(); ++i) {
    if (X[i] == c) {
      cnt++;
    } else {
      v.push_back(cnt);
      cnt = 1;
      c = X[i];
    }
  }
  v.push_back(cnt);
  if (X[X.size() - 1] == 'S') v.push_back(0);
  int ans = 0;
  for (int i = 0; i < v.size(); i += 2) {
    ans += min(v[i], v[i + 1]) * 2;
  }
  cout << X.length() - ans << endl;
}
