#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9 + 7;
const long long LINF = 1e18;
using namespace std;
int main() {
  string x;
  cin >> x;
  int n = x.size();
  int t = 0;
  for (int i = 0; i < (int)(n); i++) {
    if (x[i] != 'T') break;
    t++;
  }
  int s = 0;
  for (int i = ((int)(n)-1); i >= 0; i--) {
    if (x[i] != 'S') break;
    s++;
  }
  cout << n - 2 * min(n / 2 - s, n / 2 - t) << endl;
}
