#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin >> S;
  vector<int> N;
  char c = 'T';
  int count = 0;
  for (int i = 0; i < S.size(); i++) {
    if (c == S[i]) {
      count++;
      continue;
    }
    N.push_back(count);
    c = S[i];
    count = 1;
  }
  N.push_back(count);
  for (int i = 1; i < N.size() - 1; i += 2) {
    if (N[i] - N[i + 1] >= 0) {
      N[i] -= N[i + 1];
      N[i + 1] = 0;
    } else {
      N[i + 1] -= N[i];
      N[i] = 0;
    }
  }
  int ans = 0;
  for (int i = 0; i < N.size(); i++) {
    ans += N[i];
  }
  cout << ans << endl;
  return 0;
}
