#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9 + 7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
class Edge {
 public:
  int from, to, value;
  Edge(int a, int b, int c) {
    from = a;
    to = b;
    value = c;
  }
  Edge(int a, int b) {
    from = a;
    to = b;
  }
};
int main() {
  string str;
  cin >> str;
  stack<char> sta;
  for (int a = 0; a < str.size(); a++) {
    if (str.at(a) == 'S') {
      sta.push(str.at(a));
    }
    if (str.at(a) == 'T' && (sta.top() == 'T' || sta.empty())) {
      sta.push(str.at(a));
    } else if (str.at(a) == 'T' && sta.top() == 'S') {
      sta.pop();
    }
  }
  cout << (sta.size()) << endl;
  return 0;
}
