#include <bits/stdc++.h>
using namespace std;
int main() {
  string x;
  int n = x.size();
  int t = 0;
  int s = 0;
  int maxt = 0;
  int maxs = 0;
  for (int i = 0; i < n; i++) {
    if (x[i] == 'T') {
      t++;
    } else {
      t--;
    }
    if (maxt < t) {
      maxt = t;
    }
  }
  for (int i = n - 1; i >= 0; i--) {
    if (x[i] == 'S') {
      s++;
    } else {
      s--;
    }
    if (maxs < s) {
      maxs = s;
    }
  }
  int ans = maxt + maxs;
  cout << ans;
  cout << endl;
  return 0;
}
