#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;
ll dp[60][6000];
int main() {
  string x;
  cin >> x;
  int s = 0, t = 0, cnt = 0;
  int i = 0;
  while (x[i++] == 'T') t++;
  i = x.size() - 1;
  while (x[i--] == 'S') s++;
  cnt = t + s;
  int tt = 0, ts = 0;
  for (int i = t; i < x.size() - s; ++i) {
    if (x[i] == 'S')
      ts++;
    else
      tt++;
  }
  cnt += abs(tt - ts);
  cout << cnt << endl;
  return 0;
}
