#include <bits/stdc++.h>
using namespace std;
static const int INTINF = (2147483647 >> 1);
static const long long LLINF = (9223372036854775807 >> 1);
static const int MAX = 1e5 + 1;
static const long long MOD = 1e9 + 7;
namespace Printer {
template <class T>
void print(T x) {
  cout << x << endl;
}
template <class T>
void print(T x, T y) {
  cout << x << "," << y << endl;
}
template <class T>
void print(vector<T> v) {
  for (int i = 0; i < (v.size()); ++i) {
    if (i) cout << " ";
    cout << v[i];
  }
  cout << endl;
}
template <class T>
void print(vector<vector<T> > vv) {
  for (int i = 0; i < (vv.size()); ++i) {
    for (int j = 0; j < (vv[i].size()); ++j) {
      if (j) cout << " ";
      cout << vv[i][j];
    }
    cout << endl;
  }
}
void print(pair<int, int> p) {
  cout << "(" << p.first << ", " << p.second << ")" << endl;
}
};  // namespace Printer
using namespace Printer;
vector<pair<char, int> > Ranlength(string str) {
  vector<pair<char, int> > ranlength;
  pair<char, int> f;
  char lastChar;
  int cnt = 0;
  for (int i = 0; i < (str.size()); ++i) {
    if (lastChar != str[i] || i == str.size()) {
      if (i != 0) {
        f = make_pair(lastChar, cnt);
        ranlength.push_back(f);
      }
      lastChar = str[i];
      cnt = 1;
    } else {
      cnt++;
    }
  }
  f = make_pair(lastChar, cnt);
  ranlength.push_back(f);
  return ranlength;
}
int main(int argc, const char* argv[]) {
  string str;
  cin >> str;
  int bef = 1;
  int i = 0;
  int limit = str.size();
  while (i < limit) {
    i++;
    if (str[i - 1] == 'S' && str[i] == 'T') {
      str = str.substr(0, max(0, i - 1)) + str.substr(i + 1);
      limit = str.size();
      i -= 2;
      if (i < 0) i = 0;
    }
  }
  print(str.size());
  return 0;
}
