#include <bits/stdc++.h>
using namespace std;
template <typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
  if (!v.empty()) {
    out << '[';
    std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
    out << "\b\b]";
  }
  return out;
}
template <typename T1, typename T2>
std::ostream &operator<<(std::ostream &out, const std::pair<T1, T2> &p) {
  out << "[" << p.first << ", " << p.second << "]";
  return out;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int flag = false;
  for (int j = 0; j < 10000; j++) {
    for (int i = 0; i < s.size() - 1; i++) {
      if (s.size() == 0) {
        cout << "0" << endl;
        return 0;
      }
      if (s[i] == 'S' && s[i + 1] == 'T') {
        s.erase(s.begin() + i + 1);
        s.erase(s.begin() + i);
        flag = true;
        break;
      }
      if (flag == true) {
        flag = false;
        break;
      }
    }
  }
  cout << s.size() << endl;
}
