#include <bits/stdc++.h>
using ll = long long;
using namespace std;
const ll MM = 1000000000;
const ll mod = MM + 7;
int main() {
  string x;
  cin >> x;
  int x_size = 0;
  for (int i = 0; i < 200; i++) {
    x_size = x.size();
    for (int j = 0; j < 200; j++) {
      if (x[j] == 'S' && x[j + 1] == 'T') {
        x.erase(x.begin() + j);
        x.erase(x.begin() + j);
      }
    }
    if (x_size == x.size()) break;
  }
  cout << x.size() << endl;
}
