#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
int main() {
  string s;
  cin >> s;
  vector<int> cnts;
  bool isS = true;
  int cnt = 0;
  for (int i = 0; i < (int)(s.size()); i++) {
    if (isS && s[i] == 'T') {
      cnts.push_back(cnt);
      isS = !isS;
      cnt = 0;
    } else if (!isS && s[i] == 'S') {
      cnts.push_back(cnt);
      isS = !isS;
      cnt = 0;
    }
    cnt++;
  }
  cnts.push_back(cnt);
  if (s[s.size() - 1] != 'S') cnts.push_back(0);
  int ans = (cnts[1] - cnts[0]) + cnts[cnts.size() - 1];
  if (ans % 2 != 0) ans++;
  cout << ans << endl;
  return 0;
}
