#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;
  while (true) {
    int w = -1;
    for (int a = 0; a < str.size() - 1; a++) {
      if (str.at(a) == 'S' && str.at(a + 1) == 'T') {
        w = a;
        break;
      }
    }
    if (w == -1) {
      break;
    } else {
      str.erase(str.begin() + w, str.begin() + w + 2);
    }
  }
  cout << (str.size()) << endl;
  return 0;
}
