#include <bits/stdc++.h>
const int INF = 100000000;
using namespace std;
string s;
vector<int> st;
void solve() {
  char pre = 'a';
  for (int i = 0; i < s.size(); i++) {
    if (pre == 'S' && s[i] == 'T') {
      st.push_back(i - 1);
    }
    pre = s[i];
  }
  int res = s.size();
  for (auto x : st) {
    int s_idx = x;
    int t_idx = x + 1;
    while (s[s_idx] == 'S' && s[t_idx] == 'T') {
      s[s_idx] = 'a';
      s[t_idx] = 'a';
      res -= 2;
      if (s_idx == 0 || t_idx == s.size() - 1) break;
      s_idx--;
      t_idx++;
    }
  }
  cout << res << endl;
}
int main() {
  cin >> s;
  solve();
  return 0;
}
