#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int len = s.size();
  for (int i = 0; i < s.size(); i++) {
    if ((s[i] == 'T' && s[i + 1] == 'T') || (s[i] == 'S' && s[i + 1] == 'S'))
      len--;
  }
  cout << len << endl;
  return 0;
}
