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