#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const int INF = 1e9;
const lint LINF = 1e18;
const lint MOD = 1e9 + 7;
const double EPS = 1e-10;
int main() {
  string S;
  cin >> S;
  int N = S.size();
  queue<int> st{};
  for (int i = 1; i < N; i++)
    if (S.substr(i - 1, 2) == "ST") {
      st.push(i);
    }
  int ans = 0;
  while (!st.empty()) {
    int i = st.front();
    st.pop();
    int left, right;
    left = right = i;
    while (0 < left and right < N and S[left - 1] == 'S' and S[right] == 'T') {
      left--, right++;
      ans++;
    }
  }
  ans = N - (ans * 2);
  cout << ans << endl;
  return 0;
}
