#include <bits/stdc++.h>
using namespace std;
vector<long long int> vec;
vector<vector<long long int> > vec2;
long long int MOD = 1000000007;
long long int INF = 1145141919454519;
int main() {
  string X;
  cin >> X;
  X = 'T' + X;
  long long int ans = 0;
  long long int t_cn = 0;
  long long int s_cn = 0;
  for (long long int i = X.length() - 1; i >= 0; i--) {
    if (X[i] == 'T') t_cn++;
    if (X[i] == 'S') s_cn++;
    if (X[i] == 'S' && X[i - 1] == 'T') {
      ans += 2 * min(t_cn, s_cn);
      t_cn = 0;
      s_cn = 0;
    }
  }
  cout << X.length() - ans - 1 << endl;
}
